home *** CD-ROM | disk | FTP | other *** search
MacBinary | 1995-05-13 | 67.0 KB | [ TEXT/KAHL]
open in: MacOS 8.1
extracted
|
Win98
extracted
|
DOS
extracted
browse contents |
view JSON data
|
view as text
This file was processed as: MacBinary
(archive/macBinary ).
id metadata key value macFileType [ TEXT] macFileCreator [ KAHL]
hex view +--------+-------------------------+-------------------------+--------+--------+ |00000000| 00 14 53 74 61 6e 64 61 | 72 64 20 41 75 74 6f 70 |..Standa|rd Autop| |00000010| 69 6c 6f 74 2e 63 00 00 | 00 00 00 00 00 00 00 00 |ilot.c..|........| |00000020| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........| |00000030| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........| |00000040| 00 54 45 58 54 4b 41 48 | 4c 00 00 00 00 00 00 00 |.TEXTKAH|L.......| |00000050| 00 00 00 00 01 09 84 00 | 00 01 7e ab da 8a 4e ab |........|..~...N.| |00000060| da 8a 4e 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |..N.....|........| |00000070| 00 00 00 00 00 00 00 00 | 00 00 81 81 0c a8 00 00 |........|........| |00000080| 2f 2f 20 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |// *****|********| |00000090| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********| |000000a0| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********| |000000b0| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********| |000000c0| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 0d |********|*******.| |000000d0| 2f 2f 0d 2f 2f 20 42 6f | 6c 6f 20 73 74 61 6e 64 |//.// Bo|lo stand| |000000e0| 61 72 64 20 41 75 74 6f | 70 69 6c 6f 74 20 42 72 |ard Auto|pilot Br| |000000f0| 61 69 6e 0d 2f 2f 20 28 | 43 29 20 31 39 39 33 2d |ain.// (|C) 1993-| |00000100| 31 39 39 35 20 53 74 75 | 61 72 74 20 43 68 65 73 |1995 Stu|art Ches| |00000110| 68 69 72 65 20 3c 63 68 | 65 73 68 69 72 65 40 63 |hire <ch|eshire@c| |00000120| 73 2e 73 74 61 6e 66 6f | 72 64 2e 65 64 75 3e 0d |s.stanfo|rd.edu>.| |00000130| 2f 2f 20 49 20 6d 61 6b | 65 20 6e 6f 20 63 6c 61 |// I mak|e no cla| |00000140| 69 6d 73 20 74 68 61 74 | 20 74 68 69 73 20 69 73 |ims that| this is| |00000150| 20 67 6f 6f 64 20 63 6f | 64 65 2e 20 49 74 20 69 | good co|de. It i| |00000160| 73 20 70 72 6f 76 69 64 | 65 64 20 73 6f 6c 65 6c |s provid|ed solel| |00000170| 79 20 61 73 0d 2f 2f 20 | 73 69 6d 70 6c 65 20 65 |y as.// |simple e| |00000180| 78 61 6d 70 6c 65 20 63 | 6f 64 65 20 74 6f 20 61 |xample c|ode to a| |00000190| 73 73 69 73 74 20 69 6e | 20 77 72 69 74 69 6e 67 |ssist in| writing| |000001a0| 20 42 6f 6c 6f 20 70 6c | 75 67 2d 69 6e 20 42 72 | Bolo pl|ug-in Br| |000001b0| 61 69 6e 20 6d 6f 64 75 | 6c 65 73 2e 0d 2f 2f 20 |ain modu|les..// | |000001c0| 49 20 64 6f 20 6e 6f 74 | 20 68 61 76 65 20 74 68 |I do not| have th| |000001d0| 65 20 74 69 6d 65 20 74 | 6f 20 74 69 64 79 20 69 |e time t|o tidy i| |000001e0| 74 20 75 70 20 61 6e 64 | 20 6d 61 6b 65 20 69 74 |t up and| make it| |000001f0| 20 65 6c 65 67 61 6e 74 | 20 61 74 20 61 6c 6c 2e | elegant| at all.| |00000200| 0d 2f 2f 20 49 74 27 73 | 20 70 6f 6f 72 6c 79 20 |.// It's| poorly | |00000210| 73 74 72 75 63 74 75 72 | 65 64 20 61 6e 64 20 69 |structur|ed and i| |00000220| 74 20 75 73 65 73 20 66 | 61 72 20 74 6f 6f 20 6d |t uses f|ar too m| |00000230| 61 6e 79 20 67 6c 6f 62 | 61 6c 20 76 61 72 69 61 |any glob|al varia| |00000240| 62 6c 65 73 2e 0d 2f 2f | 0d 2f 2f 20 56 65 72 73 |bles..//|.// Vers| |00000250| 69 6f 6e 20 68 69 73 74 | 6f 72 79 3a 0d 2f 2f 20 |ion hist|ory:.// | |00000260| 30 2e 39 20 31 32 74 68 | 20 4d 61 79 20 31 39 39 |0.9 12th| May 199| |00000270| 35 2e 20 55 70 64 61 74 | 65 64 20 74 6f 20 6e 65 |5. Updat|ed to ne| |00000280| 77 20 76 65 72 73 69 6f | 6e 20 33 20 42 72 61 69 |w versio|n 3 Brai| |00000290| 6e 20 69 6e 74 65 72 66 | 61 63 65 2e 0d 2f 2f 20 |n interf|ace..// | |000002a0| 20 20 20 20 4d 61 64 65 | 20 69 74 20 70 72 65 66 | Made| it pref| |000002b0| 65 72 20 62 75 69 6c 64 | 69 6e 67 20 73 6c 69 67 |er build|ing slig| |000002c0| 68 74 6c 79 20 61 68 65 | 61 64 2c 20 72 61 74 68 |htly ahe|ad, rath| |000002d0| 65 72 20 74 68 61 6e 20 | 75 6e 64 65 72 20 74 68 |er than |under th| |000002e0| 65 20 74 61 6e 6b 2c 0d | 2f 2f 20 20 20 20 20 77 |e tank,.|// w| |000002f0| 68 65 6e 20 6d 6f 76 69 | 6e 67 20 61 74 20 61 20 |hen movi|ng at a | |00000300| 72 65 61 73 6f 6e 61 62 | 6c 65 20 73 70 65 65 64 |reasonab|le speed| |00000310| 20 28 73 70 65 65 64 73 | 20 3e 3d 20 66 6f 72 65 | (speeds| >= fore| |00000320| 73 74 20 73 70 65 65 64 | 29 0d 2f 2f 20 30 2e 38 |st speed|).// 0.8| |00000330| 20 32 32 6e 64 20 4e 6f | 76 65 20 31 39 39 33 2e | 22nd No|ve 1993.| |00000340| 20 41 64 64 65 64 20 22 | 44 6f 20 42 75 69 6c 64 | Added "|Do Build| |00000350| 69 6e 67 22 20 6d 65 6e | 75 20 6f 70 74 69 6f 6e |ing" men|u option| |00000360| 2c 20 61 6e 64 20 6d 6f | 76 65 64 0d 2f 2f 20 20 |, and mo|ved.// | |00000370| 20 20 20 64 65 63 69 64 | 65 5f 62 75 69 6c 64 69 | decid|e_buildi| |00000380| 6e 67 28 6e 65 61 72 78 | 2c 20 6e 65 61 72 79 29 |ng(nearx|, neary)| |00000390| 20 63 61 6c 6c 20 74 6f | 20 69 6e 73 69 64 65 20 | call to| inside | |000003a0| 22 69 66 20 28 63 6f 72 | 72 65 63 74 69 6f 6e c9 |"if (cor|rection.| |000003b0| 22 20 73 74 61 74 65 6d | 65 6e 74 0d 2f 2f 20 30 |" statem|ent.// 0| |000003c0| 2e 37 20 36 74 68 20 4e | 6f 76 20 31 39 39 33 2e |.7 6th N|ov 1993.| |000003d0| 20 43 6f 6e 76 65 72 74 | 65 64 20 74 6f 20 41 2d | Convert|ed to A-| |000003e0| 53 74 61 72 20 68 65 75 | 72 69 73 74 69 63 2c 20 |Star heu|ristic, | |000003f0| 61 64 64 65 64 20 72 6f | 75 74 65 20 61 6c 67 6f |added ro|ute algo| |00000400| 72 69 74 68 6d 0d 2f 2f | 20 20 20 20 20 64 65 62 |rithm.//| deb| |00000410| 75 67 67 69 6e 67 20 77 | 69 6e 64 6f 77 20 61 6e |ugging w|indow an| |00000420| 64 20 6d 61 64 65 20 74 | 61 6e 6b 73 20 73 65 65 |d made t|anks see| |00000430| 6b 20 6f 75 74 20 62 6f | 61 74 73 20 66 6f 72 20 |k out bo|ats for | |00000440| 74 72 61 6e 73 70 6f 72 | 74 61 74 69 6f 6e 2e 0d |transpor|tation..| |00000450| 2f 2f 20 20 20 20 20 52 | 65 63 6f 72 64 20 74 69 |// R|ecord ti| |00000460| 6d 65 20 66 6f 72 20 45 | 76 65 72 61 72 64 20 49 |me for E|verard I| |00000470| 73 6c 61 6e 64 20 31 38 | 20 6d 69 6e 20 33 30 20 |sland 18| min 30 | |00000480| 73 65 63 73 0d 2f 2f 20 | 30 2e 36 20 31 39 74 68 |secs.// |0.6 19th| |00000490| 20 4f 63 74 20 31 39 39 | 33 2e 20 4d 61 64 65 20 | Oct 199|3. Made | |000004a0| 69 74 20 6e 6f 74 20 74 | 72 79 20 74 6f 20 70 69 |it not t|ry to pi| |000004b0| 63 6b 20 75 70 20 70 69 | 6c 6c 62 6f 78 65 73 20 |ck up pi|llboxes | |000004c0| 77 68 69 63 68 20 61 72 | 65 20 73 69 74 74 69 6e |which ar|e sittin| |000004d0| 67 20 69 6e 20 64 65 65 | 70 20 73 65 61 2e 0d 2f |g in dee|p sea../| |000004e0| 2f 20 30 2e 35 20 31 33 | 74 68 20 4f 63 74 20 31 |/ 0.5 13|th Oct 1| |000004f0| 39 39 33 2e 20 4d 61 6a | 6f 72 20 69 6d 70 72 6f |993. Maj|or impro| |00000500| 76 65 6d 65 6e 74 73 20 | 74 6f 20 72 6f 75 74 65 |vements |to route| |00000510| 20 66 69 6e 64 69 6e 67 | 20 61 6e 64 20 64 65 63 | finding| and dec| |00000520| 69 73 69 6f 6e 20 6d 61 | 6b 69 6e 67 2e 20 50 69 |ision ma|king. Pi| |00000530| 6c 6c 62 6f 78 0d 2f 2f | 20 20 20 20 20 66 69 72 |llbox.//| fir| |00000540| 69 6e 67 20 61 72 65 61 | 73 20 75 73 65 64 2c 20 |ing area|s used, | |00000550| 63 6c 65 61 72 20 70 61 | 74 68 20 72 6f 75 74 69 |clear pa|th routi| |00000560| 6e 65 73 2c 20 72 65 76 | 69 73 65 64 20 70 72 6f |nes, rev|ised pro| |00000570| 67 72 65 73 73 2f 62 6f | 72 65 64 6f 6d 20 72 6f |gress/bo|redom ro| |00000580| 75 74 69 6e 65 73 2e 0d | 2f 2f 20 30 2e 34 20 37 |utines..|// 0.4 7| |00000590| 74 68 20 4f 63 74 20 31 | 39 39 33 2e 20 52 6f 75 |th Oct 1|993. Rou| |000005a0| 74 65 20 66 69 6e 64 69 | 6e 67 20 73 77 69 74 63 |te findi|ng switc| |000005b0| 68 65 64 20 74 6f 20 6d | 75 6c 74 69 2d 70 61 72 |hed to m|ulti-par| |000005c0| 61 6d 65 74 65 72 20 64 | 65 63 69 73 69 6f 6e 2e |ameter d|ecision.| |000005d0| 0d 2f 2f 20 30 2e 33 20 | 31 73 74 20 4f 63 74 20 |.// 0.3 |1st Oct | |000005e0| 31 39 39 33 2e 20 4e 65 | 77 20 6d 65 6e 75 20 6f |1993. Ne|w menu o| |000005f0| 70 74 69 6f 6e 73 2c 20 | 69 6e 63 6c 75 64 69 6e |ptions, |includin| |00000600| 67 20 22 61 73 73 61 73 | 73 69 6e 22 20 6d 6f 64 |g "assas|sin" mod| |00000610| 65 2e 0d 2f 2f 20 30 2e | 32 20 32 36 74 68 20 4d |e..// 0.|2 26th M| |00000620| 61 79 20 31 39 39 33 2e | 20 52 65 6c 65 61 73 65 |ay 1993.| Release| |00000630| 64 20 77 69 74 68 20 42 | 6f 6c 6f 20 30 2e 39 39 |d with B|olo 0.99| |00000640| 2e 0d 2f 2f 20 30 2e 31 | 20 32 31 73 74 20 46 65 |..// 0.1| 21st Fe| |00000650| 62 20 31 39 39 33 2e 20 | 42 75 69 6c 74 20 69 6e |b 1993. |Built in| |00000660| 74 6f 20 42 6f 6c 6f 20 | 30 2e 39 38 20 61 73 20 |to Bolo |0.98 as | |00000670| 22 41 75 74 6f 70 69 6c | 6f 74 22 0d 0d 23 64 65 |"Autopil|ot"..#de| |00000680| 66 69 6e 65 20 41 55 54 | 4f 5f 44 45 42 55 47 20 |fine AUT|O_DEBUG | |00000690| 30 0d 0d 2f 2f 20 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |0..// **|********| |000006a0| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********| |000006b0| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********| |000006c0| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********| |000006d0| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********| |000006e0| 2a 2a 0d 0d 2f 2f 20 44 | 65 66 69 6e 65 20 61 6e |**..// D|efine an| |000006f0| 20 69 6e 74 65 67 65 72 | 20 73 71 75 61 72 65 20 | integer| square | |00000700| 72 6f 6f 74 20 72 6f 75 | 74 69 6e 65 0d 23 69 6e |root rou|tine.#in| |00000710| 63 6c 75 64 65 20 3c 46 | 69 78 4d 61 74 68 2e 68 |clude <F|ixMath.h| |00000720| 3e 0d 23 64 65 66 69 6e | 65 20 73 71 72 74 28 58 |>.#defin|e sqrt(X| |00000730| 29 20 28 46 72 61 63 53 | 71 72 74 28 58 29 20 3e |) (FracS|qrt(X) >| |00000740| 3e 20 31 35 29 0d 0d 2f | 2f 20 2a 2a 2a 2a 2a 2a |> 15)../|/ ******| |00000750| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********| |00000760| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********| |00000770| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********| |00000780| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********| |00000790| 2a 2a 2a 2a 2a 2a 0d 0d | 23 69 6e 63 6c 75 64 65 |******..|#include| |000007a0| 20 22 76 73 70 72 69 6e | 74 66 2e 68 22 0d 23 69 | "vsprin|tf.h".#i| |000007b0| 6e 63 6c 75 64 65 20 22 | 42 72 61 69 6e 2e 68 22 |nclude "|Brain.h"| |000007c0| 0d 0d 2f 2f 20 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |..// ***|********| |000007d0| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********| |000007e0| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********| |000007f0| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********| |00000800| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********| |00000810| 2a 0d 0d 23 64 65 66 69 | 6e 65 20 61 62 73 28 58 |*..#defi|ne abs(X| |00000820| 29 20 28 28 28 58 29 20 | 3c 20 30 20 29 20 3f 20 |) (((X) |< 0 ) ? | |00000830| 2d 28 58 29 20 3a 20 28 | 58 29 29 0d 23 64 65 66 |-(X) : (|X)).#def| |00000840| 69 6e 65 20 6d 61 78 28 | 58 2c 59 29 20 28 28 58 |ine max(|X,Y) ((X| |00000850| 29 20 3e 20 28 59 29 20 | 3f 20 28 58 29 20 3a 20 |) > (Y) |? (X) : | |00000860| 28 59 29 29 0d 23 64 65 | 66 69 6e 65 20 6d 69 6e |(Y)).#de|fine min| |00000870| 28 58 2c 59 29 20 28 28 | 58 29 20 3c 20 28 59 29 |(X,Y) ((|X) < (Y)| |00000880| 20 3f 20 28 58 29 20 3a | 20 28 59 29 29 0d 0d 2f | ? (X) :| (Y))../| |00000890| 2f 20 70 69 6c 6c 70 69 | 63 6b 75 70 5f 78 20 61 |/ pillpi|ckup_x a| |000008a0| 6e 64 20 79 20 61 72 65 | 20 75 73 65 64 20 74 6f |nd y are| used to| |000008b0| 20 72 65 63 6f 72 64 20 | 74 68 65 20 6c 6f 63 61 | record |the loca| |000008c0| 74 69 6f 6e 20 6f 66 20 | 74 68 65 20 6c 61 73 74 |tion of |the last| |000008d0| 0d 2f 2f 20 70 69 6c 6c | 62 6f 78 20 70 69 63 6b |.// pill|box pick| |000008e0| 65 64 20 75 70 20 69 6e | 20 63 61 73 65 20 69 74 |ed up in| case it| |000008f0| 20 74 75 72 6e 73 20 6f | 75 74 20 74 6f 20 62 65 | turns o|ut to be| |00000900| 20 66 61 74 61 6c 20 64 | 65 65 70 20 73 65 61 20 | fatal d|eep sea | |00000910| 75 6e 64 65 72 6e 65 61 | 74 68 0d 0d 6c 6f 63 61 |undernea|th..loca| |00000920| 6c 20 63 6f 6e 73 74 20 | 42 72 61 69 6e 49 6e 66 |l const |BrainInf| |00000930| 6f 20 2a 69 6e 66 6f 3b | 0d 6c 6f 63 61 6c 20 6c |o *info;|.local l| |00000940| 6f 6e 67 20 54 69 6d 65 | 4e 6f 77 3b 0d 6c 6f 63 |ong Time|Now;.loc| |00000950| 61 6c 20 4d 41 50 5f 58 | 20 6e 65 61 72 78 2c 20 |al MAP_X| nearx, | |00000960| 70 69 6c 6c 70 69 63 6b | 75 70 5f 78 2c 20 66 61 |pillpick|up_x, fa| |00000970| 74 61 6c 5f 78 3b 0d 6c | 6f 63 61 6c 20 4d 41 50 |tal_x;.l|ocal MAP| |00000980| 5f 59 20 6e 65 61 72 79 | 2c 20 70 69 6c 6c 70 69 |_Y neary|, pillpi| |00000990| 63 6b 75 70 5f 79 2c 20 | 66 61 74 61 6c 5f 79 3b |ckup_y, |fatal_y;| |000009a0| 0d 6c 6f 63 61 6c 20 4d | 41 50 5f 58 20 74 61 6e |.local M|AP_X tan| |000009b0| 6b 6c 65 66 74 78 2c 20 | 74 61 6e 6b 72 69 67 68 |kleftx, |tankrigh| |000009c0| 74 78 3b 0d 6c 6f 63 61 | 6c 20 4d 41 50 5f 59 20 |tx;.loca|l MAP_Y | |000009d0| 74 61 6e 6b 74 6f 70 79 | 2c 20 74 61 6e 6b 62 6f |tanktopy|, tankbo| |000009e0| 74 74 6f 6d 79 3b 0d 6c | 6f 63 61 6c 20 42 6f 6f |ttomy;.l|ocal Boo| |000009f0| 6c 65 61 6e 20 74 61 6e | 6b 5f 63 6c 6f 73 65 5f |lean tan|k_close_| |00000a00| 74 6f 5f 6d 69 6e 65 3b | 0d 6c 6f 63 61 6c 20 42 |to_mine;|.local B| |00000a10| 6f 6f 6c 65 61 6e 20 73 | 74 69 6c 6c 5f 6f 6e 5f |oolean s|till_on_| |00000a20| 62 6f 61 74 3b 09 2f 2f | 20 53 65 74 20 75 6e 74 |boat;.//| Set unt| |00000a30| 69 6c 20 74 61 6e 6b 20 | 67 65 74 73 20 6f 66 66 |il tank |gets off| |00000a40| 20 62 6f 61 74 0d 6c 6f | 63 61 6c 20 42 59 54 45 | boat.lo|cal BYTE| |00000a50| 20 6c 61 6e 64 5f 64 69 | 72 65 63 74 69 6f 6e 3b | land_di|rection;| |00000a60| 09 09 2f 2f 20 49 6e 69 | 74 69 61 6c 20 67 75 65 |..// Ini|tial gue| |00000a70| 73 73 20 61 74 20 77 68 | 65 72 65 20 74 68 65 20 |ss at wh|ere the | |00000a80| 6c 61 6e 64 20 69 73 0d | 0d 2f 2f 20 49 66 20 63 |land is.|.// If c| |00000a90| 61 6e 6e 6f 74 20 72 65 | 61 63 68 20 61 20 74 61 |annot re|ach a ta| |00000aa0| 72 67 65 74 2c 20 67 65 | 74 20 62 6f 72 65 64 20 |rget, ge|t bored | |00000ab0| 61 6e 64 20 69 67 6e 6f | 72 65 20 69 74 20 61 66 |and igno|re it af| |00000ac0| 74 65 72 20 32 30 20 73 | 65 63 6f 6e 64 73 0d 23 |ter 20 s|econds.#| |00000ad0| 64 65 66 69 6e 65 20 41 | 54 54 45 4e 54 49 4f 4e |define A|TTENTION| |00000ae0| 5f 53 50 41 4e 20 28 36 | 30 2a 32 30 29 0d 23 64 |_SPAN (6|0*20).#d| |00000af0| 65 66 69 6e 65 20 4d 41 | 58 5f 56 49 53 5f 52 41 |efine MA|X_VIS_RA| |00000b00| 4e 47 45 20 30 78 37 46 | 46 46 0d 23 64 65 66 69 |NGE 0x7F|FF.#defi| |00000b10| 6e 65 20 44 45 46 45 4e | 53 49 56 45 5f 52 41 4e |ne DEFEN|SIVE_RAN| |00000b20| 47 45 20 30 78 41 30 30 | 0d 0d 74 79 70 65 64 65 |GE 0xA00|..typede| |00000b30| 66 20 73 74 72 75 63 74 | 0d 09 7b 0d 09 75 5f 6c |f struct|..{..u_l| |00000b40| 6f 6e 67 20 72 65 6d 61 | 69 6e 69 6e 67 5f 70 72 |ong rema|ining_pr| |00000b50| 6f 67 72 65 73 73 3b 09 | 2f 2f 20 43 75 72 72 65 |ogress;.|// Curre| |00000b60| 6e 74 20 27 62 65 73 74 | 27 20 70 6f 69 6e 74 20 |nt 'best|' point | |00000b70| 73 6f 20 66 61 72 0d 09 | 6c 6f 6e 67 20 6c 61 73 |so far..|long las| |00000b80| 74 5f 70 72 6f 67 72 65 | 73 73 3b 09 09 09 2f 2f |t_progre|ss;...//| |00000b90| 20 4c 61 73 74 20 74 69 | 6d 65 20 70 72 6f 67 72 | Last ti|me progr| |00000ba0| 65 73 73 20 77 61 73 20 | 6d 61 64 65 0d 09 6c 6f |ess was |made..lo| |00000bb0| 6e 67 20 69 67 6e 6f 72 | 65 5f 75 6e 74 69 6c 3b |ng ignor|e_until;| |00000bc0| 09 09 09 2f 2f 20 77 68 | 65 6e 20 77 65 20 61 72 |...// wh|en we ar| |00000bd0| 65 20 62 6f 72 65 64 20 | 77 69 74 68 20 73 6f 6d |e bored |with som| |00000be0| 65 74 68 69 6e 67 0d 09 | 7d 20 50 72 6f 67 72 65 |ething..|} Progre| |00000bf0| 73 73 49 6e 66 6f 3b 0d | 23 64 65 66 69 6e 65 20 |ssInfo;.|#define | |00000c00| 4d 41 58 5f 50 52 4f 47 | 52 45 53 53 20 30 78 46 |MAX_PROG|RESS 0xF| |00000c10| 46 46 46 46 46 46 46 0d | 6c 6f 63 61 6c 20 6c 6f |FFFFFFF.|local lo| |00000c20| 6e 67 20 62 6f 72 65 64 | 6f 6d 74 69 6d 65 20 3d |ng bored|omtime =| |00000c30| 20 41 54 54 45 4e 54 49 | 4f 4e 5f 53 50 41 4e 3b | ATTENTI|ON_SPAN;| |00000c40| 0d 6c 6f 63 61 6c 20 50 | 72 6f 67 72 65 73 73 49 |.local P|rogressI| |00000c50| 6e 66 6f 20 2a 74 61 6e | 6b 70 72 6f 67 72 65 73 |nfo *tan|kprogres| |00000c60| 73 2c 20 2a 70 69 6c 6c | 70 72 6f 67 72 65 73 73 |s, *pill|progress| |00000c70| 2c 20 2a 62 61 73 65 70 | 72 6f 67 72 65 73 73 3b |, *basep|rogress;| |00000c80| 0d 6c 6f 63 61 6c 20 50 | 72 6f 67 72 65 73 73 49 |.local P|rogressI| |00000c90| 6e 66 6f 20 73 63 6f 75 | 74 69 6e 67 70 72 6f 67 |nfo scou|tingprog| |00000ca0| 72 65 73 73 2c 20 6d 61 | 6e 72 65 73 63 75 65 70 |ress, ma|nrescuep| |00000cb0| 72 6f 67 72 65 73 73 3b | 0d 2f 2f 6c 6f 63 61 6c |rogress;|.//local| |00000cc0| 20 75 5f 6c 6f 6e 67 20 | 70 72 65 76 69 6f 75 73 | u_long |previous| |00000cd0| 5f 63 6c 6f 73 65 73 74 | 5f 64 69 73 74 20 3d 20 |_closest|_dist = | |00000ce0| 4d 41 58 5f 56 49 53 5f | 52 41 4e 47 45 3b 0d 2f |MAX_VIS_|RANGE;./| |00000cf0| 2f 6c 6f 63 61 6c 20 6c | 6f 6e 67 20 63 75 72 72 |/local l|ong curr| |00000d00| 65 6e 74 5f 61 74 74 65 | 6d 70 74 5f 74 69 6d 65 |ent_atte|mpt_time| |00000d10| 3b 0d 0d 2f 2f 20 43 61 | 6e 20 70 6c 61 63 65 20 |;..// Ca|n place | |00000d20| 70 69 6c 6c 62 6f 78 20 | 6f 6e 20 73 77 61 6d 70 |pillbox |on swamp| |00000d30| 2c 20 63 72 61 74 65 72 | 2c 20 72 6f 61 64 2c 20 |, crater|, road, | |00000d40| 72 75 62 62 6c 65 20 61 | 6e 64 20 67 72 61 73 73 |rubble a|nd grass| |00000d50| 0d 73 74 61 74 69 63 20 | 42 6f 6f 6c 65 61 6e 20 |.static |Boolean | |00000d60| 63 61 6e 5f 62 75 69 6c | 64 5f 70 69 6c 6c 62 6f |can_buil|d_pillbo| |00000d70| 78 5b 4e 55 4d 5f 54 45 | 52 52 41 49 4e 53 5d 20 |x[NUM_TE|RRAINS] | |00000d80| 3d 20 7b 20 30 2c 30 2c | 31 2c 31 2c 20 31 2c 30 |= { 0,0,|1,1, 1,0| |00000d90| 2c 31 2c 31 2c 20 30 2c | 30 2c 30 2c 30 2c 20 30 |,1,1, 0,|0,0,0, 0| |00000da0| 2c 30 20 7d 3b 0d 0d 2f | 2f 20 4b 65 79 62 6f 61 |,0 };../|/ Keyboa| |00000db0| 72 64 20 43 6f 6e 74 72 | 6f 6c 20 76 61 72 69 61 |rd Contr|ol varia| |00000dc0| 62 6c 65 73 0d 6c 6f 63 | 61 6c 20 75 5f 6c 6f 6e |bles.loc|al u_lon| |00000dd0| 67 20 6b 65 79 73 2c 20 | 74 61 70 73 2c 20 6c 61 |g keys, |taps, la| |00000de0| 73 74 5f 6b 65 79 73 2c | 20 6c 61 73 74 5f 74 61 |st_keys,| last_ta| |00000df0| 70 73 3b 0d 0d 2f 2f 20 | 4d 65 6e 75 20 68 61 6e |ps;..// |Menu han| |00000e00| 64 6c 69 6e 67 20 76 61 | 72 69 61 62 6c 65 73 20 |dling va|riables | |00000e10| 61 6e 64 20 6d 6f 64 65 | 20 73 65 74 74 69 6e 67 |and mode| setting| |00000e20| 73 0d 23 64 65 66 69 6e | 65 20 4d 79 4d 65 6e 75 |s.#defin|e MyMenu| |00000e30| 49 44 20 31 30 30 30 0d | 6c 6f 63 61 6c 20 4d 65 |ID 1000.|local Me| |00000e40| 6e 75 48 61 6e 64 6c 65 | 20 4d 79 4d 65 6e 75 3b |nuHandle| MyMenu;| |00000e50| 0d 6c 6f 63 61 6c 20 57 | 69 6e 64 6f 77 50 74 72 |.local W|indowPtr| |00000e60| 20 64 65 62 75 67 77 69 | 6e 64 6f 77 2c 20 72 6f | debugwi|ndow, ro| |00000e70| 75 74 65 77 69 6e 64 6f | 77 3b 0d 0d 6c 6f 63 61 |utewindo|w;..loca| |00000e80| 6c 20 42 6f 6f 6c 65 61 | 6e 20 64 6f 5f 65 78 70 |l Boolea|n do_exp| |00000e90| 6c 61 69 6e 20 20 20 3d | 20 41 55 54 4f 5f 44 45 |lain =| AUTO_DE| |00000ea0| 42 55 47 3b 0d 6c 6f 63 | 61 6c 20 42 6f 6f 6c 65 |BUG;.loc|al Boole| |00000eb0| 61 6e 20 64 6f 5f 73 68 | 6f 77 72 6f 75 74 65 20 |an do_sh|owroute | |00000ec0| 3d 20 41 55 54 4f 5f 44 | 45 42 55 47 3b 0d 0d 65 |= AUTO_D|EBUG;..e| |00000ed0| 6e 75 6d 0d 09 7b 0d 09 | 6d 5f 61 62 6f 75 74 20 |num..{..|m_about | |00000ee0| 3d 20 31 2c 0d 09 6d 5f | 73 65 70 31 2c 20 6d 5f |= 1,..m_|sep1, m_| |00000ef0| 64 65 66 61 75 6c 74 2c | 20 6d 5f 61 73 73 61 73 |default,| m_assas| |00000f00| 73 69 6e 2c 20 6d 5f 70 | 69 6c 6c 68 75 6e 74 65 |sin, m_p|illhunte| |00000f10| 72 2c 20 6d 5f 62 61 73 | 65 68 75 6e 74 65 72 2c |r, m_bas|ehunter,| |00000f20| 20 6d 5f 64 65 66 65 6e | 73 69 76 65 2c 0d 09 6d | m_defen|sive,..m| |00000f30| 5f 73 65 70 32 2c 20 6d | 5f 65 78 70 6c 6f 72 65 |_sep2, m|_explore| |00000f40| 2c 20 6d 5f 6c 61 79 6d | 69 6e 65 73 2c 20 6d 5f |, m_laym|ines, m_| |00000f50| 63 6c 65 61 72 6d 69 6e | 65 73 2c 20 6d 5f 64 6f |clearmin|es, m_do| |00000f60| 62 75 69 6c 64 69 6e 67 | 2c 0d 09 6d 5f 61 74 74 |building|,..m_att| |00000f70| 61 63 6b 74 61 6e 6b 73 | 2c 20 6d 5f 61 74 74 61 |acktanks|, m_atta| |00000f80| 63 6b 70 69 6c 6c 73 2c | 20 6d 5f 61 74 74 61 63 |ckpills,| m_attac| |00000f90| 6b 62 61 73 65 73 2c 20 | 6d 5f 72 65 70 61 69 72 |kbases, |m_repair| |00000fa0| 70 69 6c 6c 73 2c 20 6d | 5f 70 6c 61 63 65 70 69 |pills, m|_placepi| |00000fb0| 6c 6c 73 2c 20 6d 5f 70 | 70 6f 66 66 65 6e 73 69 |lls, m_p|poffensi| |00000fc0| 76 65 2c 0d 09 6d 5f 73 | 65 70 33 2c 20 6d 5f 65 |ve,..m_s|ep3, m_e| |00000fd0| 78 70 6c 61 69 6e 2c 20 | 6d 5f 72 6f 75 74 65 0d |xplain, |m_route.| |00000fe0| 09 7d 3b 0d 0d 74 79 70 | 65 64 65 66 20 73 74 72 |.};..typ|edef str| |00000ff0| 75 63 74 0d 09 7b 0d 09 | 42 6f 6f 6c 65 61 6e 20 |uct..{..|Boolean | |00001000| 65 78 70 6c 6f 72 65 2c | 20 6c 61 79 6d 69 6e 65 |explore,| laymine| |00001010| 73 2c 20 63 6c 65 61 72 | 6d 69 6e 65 73 2c 20 64 |s, clear|mines, d| |00001020| 6f 62 75 69 6c 64 69 6e | 67 3b 0d 09 42 6f 6f 6c |obuildin|g;..Bool| |00001030| 65 61 6e 20 61 74 74 61 | 63 6b 74 61 6e 6b 73 2c |ean atta|cktanks,| |00001040| 20 61 74 74 61 63 6b 70 | 69 6c 6c 73 2c 20 61 74 | attackp|ills, at| |00001050| 74 61 63 6b 62 61 73 65 | 73 2c 20 72 65 70 61 69 |tackbase|s, repai| |00001060| 72 70 69 6c 6c 73 2c 20 | 70 6c 61 63 65 70 69 6c |rpills, |placepil| |00001070| 6c 73 2c 20 70 70 6f 66 | 66 65 6e 73 69 76 65 3b |ls, ppof|fensive;| |00001080| 0d 09 7d 20 53 45 54 54 | 49 4e 47 53 3b 0d 0d 2f |..} SETT|INGS;../| |00001090| 2f 20 46 6c 61 67 73 20 | 61 72 65 3a 20 20 20 20 |/ Flags |are: | |000010a0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | | |000010b0| 20 20 20 20 20 65 78 20 | 6c 6d 20 63 6d 20 64 62 | ex |lm cm db| |000010c0| 20 61 74 20 61 70 20 63 | 62 20 72 70 20 70 70 20 | at ap c|b rp pp | |000010d0| 70 6f 0d 6c 6f 63 61 6c | 20 63 6f 6e 73 74 20 53 |po.local| const S| |000010e0| 45 54 54 49 4e 47 53 20 | 73 5f 64 65 66 61 75 6c |ETTINGS |s_defaul| |000010f0| 74 20 20 20 20 3d 20 7b | 20 31 2c 20 30 2c 20 31 |t = {| 1, 0, 1| |00001100| 2c 20 31 2c 20 31 2c 20 | 31 2c 20 31 2c 20 31 2c |, 1, 1, |1, 1, 1,| |00001110| 20 31 2c 20 30 20 7d 3b | 0d 6c 6f 63 61 6c 20 63 | 1, 0 };|.local c| |00001120| 6f 6e 73 74 20 53 45 54 | 54 49 4e 47 53 20 73 5f |onst SET|TINGS s_| |00001130| 61 73 73 61 73 73 69 6e | 20 20 20 3d 20 7b 20 31 |assassin| = { 1| |00001140| 2c 20 30 2c 20 31 2c 20 | 31 2c 20 31 2c 20 30 2c |, 0, 1, |1, 1, 0,| |00001150| 20 30 2c 20 31 2c 20 31 | 2c 20 31 20 7d 3b 0d 6c | 0, 1, 1|, 1 };.l| |00001160| 6f 63 61 6c 20 63 6f 6e | 73 74 20 53 45 54 54 49 |ocal con|st SETTI| |00001170| 4e 47 53 20 73 5f 64 65 | 66 65 6e 73 69 76 65 20 |NGS s_de|fensive | |00001180| 20 3d 20 7b 20 30 2c 20 | 30 2c 20 31 2c 20 31 2c | = { 0, |0, 1, 1,| |00001190| 20 31 2c 20 31 2c 20 30 | 2c 20 31 2c 20 31 2c 20 | 1, 1, 0|, 1, 1, | |000011a0| 30 20 7d 3b 0d 6c 6f 63 | 61 6c 20 63 6f 6e 73 74 |0 };.loc|al const| |000011b0| 20 53 45 54 54 49 4e 47 | 53 20 73 5f 70 69 6c 6c | SETTING|S s_pill| |000011c0| 68 75 6e 74 65 72 20 3d | 20 7b 20 31 2c 20 30 2c |hunter =| { 1, 0,| |000011d0| 20 31 2c 20 31 2c 20 30 | 2c 20 31 2c 20 30 2c 20 | 1, 1, 0|, 1, 0, | |000011e0| 31 2c 20 31 2c 20 30 20 | 7d 3b 0d 6c 6f 63 61 6c |1, 1, 0 |};.local| |000011f0| 20 63 6f 6e 73 74 20 53 | 45 54 54 49 4e 47 53 20 | const S|ETTINGS | |00001200| 73 5f 62 61 73 65 68 75 | 6e 74 65 72 20 3d 20 7b |s_basehu|nter = {| |00001210| 20 31 2c 20 30 2c 20 31 | 2c 20 31 2c 20 30 2c 20 | 1, 0, 1|, 1, 0, | |00001220| 30 2c 20 31 2c 20 31 2c | 20 31 2c 20 30 20 7d 3b |0, 1, 1,| 1, 0 };| |00001230| 0d 6c 6f 63 61 6c 20 53 | 45 54 54 49 4e 47 53 20 |.local S|ETTINGS | |00001240| 73 3b 0d 0d 2f 2f 20 54 | 68 69 6e 6b 69 6e 67 20 |s;..// T|hinking | |00001250| 76 61 72 69 61 62 6c 65 | 73 0d 6c 6f 63 61 6c 20 |variable|s.local | |00001260| 42 6f 6f 6c 65 61 6e 20 | 73 68 6f 6f 74 69 74 2c |Boolean |shootit,| |00001270| 20 73 68 6f 6f 74 73 6f | 6f 6e 2c 20 72 75 6e 61 | shootso|on, runa| |00001280| 77 61 79 3b 0d 23 64 65 | 66 69 6e 65 20 53 48 4f |way;.#de|fine SHO| |00001290| 4f 54 5f 4e 4f 54 48 49 | 4e 47 20 30 78 46 46 46 |OT_NOTHI|NG 0xFFF| |000012a0| 46 0d 6c 6f 63 61 6c 20 | 4f 42 4a 45 43 54 20 73 |F.local |OBJECT s| |000012b0| 68 6f 6f 74 77 68 61 74 | 3b 0d 6c 6f 63 61 6c 20 |hootwhat|;.local | |000012c0| 42 6f 6f 6c 65 61 6e 20 | 2a 73 68 6f 6f 74 5f 70 |Boolean |*shoot_p| |000012d0| 61 74 68 5f 63 6f 73 74 | 73 3b 0d 6c 6f 63 61 6c |ath_cost|s;.local| |000012e0| 20 42 59 54 45 20 63 68 | 6f 73 65 6e 5f 67 75 6e | BYTE ch|osen_gun| |000012f0| 72 61 6e 67 65 3b 09 09 | 2f 2f 20 44 65 73 69 72 |range;..|// Desir| |00001300| 65 64 20 67 75 6e 20 72 | 61 6e 67 65 2c 20 66 6f |ed gun r|ange, fo| |00001310| 72 20 73 68 6f 6f 74 69 | 6e 67 20 6d 69 6e 65 73 |r shooti|ng mines| |00001320| 0d 6c 6f 63 61 6c 20 42 | 59 54 45 20 73 68 6f 6f |.local B|YTE shoo| |00001330| 74 5f 64 69 72 65 63 74 | 69 6f 6e 3b 09 09 2f 2f |t_direct|ion;..//| |00001340| 20 74 6f 20 61 69 6d 20 | 74 68 65 20 67 75 6e 20 | to aim |the gun | |00001350| 61 63 63 75 72 61 74 65 | 6c 79 0d 6c 6f 63 61 6c |accurate|ly.local| |00001360| 20 42 59 54 45 20 73 68 | 6f 6f 74 5f 64 69 72 5f | BYTE sh|oot_dir_| |00001370| 76 6f 74 65 3b 09 09 2f | 2f 20 73 68 6f 6f 74 5f |vote;../|/ shoot_| |00001380| 64 69 72 65 63 74 69 6f | 6e 20 63 6f 6e 76 65 72 |directio|n conver| |00001390| 74 65 64 20 74 6f 20 72 | 61 6e 67 65 20 30 2d 31 |ted to r|ange 0-1| |000013a0| 35 0d 6c 6f 63 61 6c 20 | 42 59 54 45 20 63 68 6f |5.local |BYTE cho| |000013b0| 73 65 6e 5f 64 69 72 65 | 63 74 69 6f 6e 3b 0d 6c |sen_dire|ction;.l| |000013c0| 6f 63 61 6c 20 42 59 54 | 45 20 66 6c 79 69 6e 67 |ocal BYT|E flying| |000013d0| 5f 73 68 65 6c 6c 73 3b | 09 09 2f 2f 20 74 6f 74 |_shells;|..// tot| |000013e0| 61 6c 20 6e 75 6d 62 65 | 72 20 6f 66 20 73 68 65 |al numbe|r of she| |000013f0| 6c 6c 73 20 69 6e 20 66 | 6c 69 67 68 74 20 61 74 |lls in f|light at| |00001400| 20 74 68 65 20 6d 6f 6d | 65 6e 74 0d 6c 6f 63 61 | the mom|ent.loca| |00001410| 6c 20 42 59 54 45 20 69 | 6e 63 6f 6d 69 6e 67 5f |l BYTE i|ncoming_| |00001420| 73 68 65 6c 6c 73 3b 09 | 09 2f 2f 20 74 6f 74 61 |shells;.|.// tota| |00001430| 6c 20 6e 75 6d 62 65 72 | 20 6f 66 20 73 68 65 6c |l number| of shel| |00001440| 6c 73 20 68 65 61 64 69 | 6e 67 20 74 6f 77 61 72 |ls headi|ng towar| |00001450| 64 73 20 75 73 0d 6c 6f | 63 61 6c 20 6c 6f 6e 67 |ds us.lo|cal long| |00001460| 20 64 69 72 65 63 74 69 | 6f 6e 5f 76 6f 74 65 73 | directi|on_votes| |00001470| 5b 31 36 5d 3b 0d 6c 6f | 63 61 6c 20 75 5f 6c 6f |[16];.lo|cal u_lo| |00001480| 6e 67 20 74 61 72 67 65 | 74 5f 64 69 73 74 61 6e |ng targe|t_distan| |00001490| 63 65 73 5b 31 36 5d 3b | 0d 6c 6f 63 61 6c 20 42 |ces[16];|.local B| |000014a0| 59 54 45 20 64 69 72 65 | 63 74 69 6f 6e 5f 6d 61 |YTE dire|ction_ma| |000014b0| 78 73 70 65 65 64 73 5b | 31 36 5d 3b 0d 0d 6c 6f |xspeeds[|16];..lo| |000014c0| 63 61 6c 20 4d 41 50 5f | 58 20 73 63 6f 75 74 78 |cal MAP_|X scoutx| |000014d0| 3b 0d 6c 6f 63 61 6c 20 | 4d 41 50 5f 59 20 73 63 |;.local |MAP_Y sc| |000014e0| 6f 75 74 79 3b 0d 23 64 | 65 66 69 6e 65 20 43 41 |outy;.#d|efine CA| |000014f0| 4e 5f 44 4f 5f 42 55 49 | 4c 44 49 4e 47 20 28 69 |N_DO_BUI|LDING (i| |00001500| 6e 66 6f 2d 3e 62 75 69 | 6c 64 2d 3e 61 63 74 69 |nfo->bui|ld->acti| |00001510| 6f 6e 20 3d 3d 20 30 20 | 26 26 20 69 6e 66 6f 2d |on == 0 |&& info-| |00001520| 3e 6d 61 6e 5f 73 74 61 | 74 75 73 20 3d 3d 20 30 |>man_sta|tus == 0| |00001530| 20 26 26 20 5c 0d 09 09 | 09 09 09 09 21 69 6e 66 | && \...|....!inf| |00001540| 6f 2d 3e 69 6e 62 6f 61 | 74 20 26 26 20 66 6c 79 |o->inboa|t && fly| |00001550| 69 6e 67 5f 73 68 65 6c | 6c 73 20 3d 3d 20 30 29 |ing_shel|ls == 0)| |00001560| 0d 23 64 65 66 69 6e 65 | 20 43 41 4e 5f 42 55 49 |.#define| CAN_BUI| |00001570| 4c 44 5f 50 49 4c 4c 42 | 4f 58 20 28 43 41 4e 5f |LD_PILLB|OX (CAN_| |00001580| 44 4f 5f 42 55 49 4c 44 | 49 4e 47 20 26 26 20 5c |DO_BUILD|ING && \| |00001590| 0d 09 09 09 09 09 09 73 | 2e 70 6c 61 63 65 70 69 |.......s|.placepi| |000015a0| 6c 6c 73 20 26 26 20 69 | 6e 66 6f 2d 3e 63 61 72 |lls && i|nfo->car| |000015b0| 72 69 65 64 70 69 6c 6c | 73 20 26 26 20 69 6e 66 |riedpill|s && inf| |000015c0| 6f 2d 3e 74 72 65 65 73 | 20 3e 3d 20 34 29 0d 0d |o->trees| >= 4)..| |000015d0| 74 79 70 65 64 65 66 20 | 73 74 72 75 63 74 20 7b |typedef |struct {| |000015e0| 20 63 68 61 72 20 78 3b | 20 63 68 61 72 20 79 3b | char x;| char y;| |000015f0| 20 7d 20 63 68 61 72 70 | 61 69 72 3b 0d 0d 74 79 | } charp|air;..ty| |00001600| 70 65 64 65 66 20 75 6e | 69 6f 6e 0d 09 7b 0d 09 |pedef un|ion..{..| |00001610| 63 68 61 72 70 61 69 72 | 20 73 32 35 5b 32 35 5d |charpair| s25[25]| |00001620| 3b 0d 09 73 74 72 75 63 | 74 20 7b 20 63 68 61 72 |;..struc|t { char| |00001630| 70 61 69 72 20 73 31 5b | 31 5d 3b 20 63 68 61 72 |pair s1[|1]; char| |00001640| 70 61 69 72 20 73 38 5b | 38 5d 3b 20 63 68 61 72 |pair s8[|8]; char| |00001650| 70 61 69 72 20 73 31 36 | 5b 31 36 5d 3b 20 7d 20 |pair s16|[16]; } | |00001660| 73 3b 0d 09 7d 20 53 55 | 52 52 4f 55 4e 44 49 4e |s;..} SU|RROUNDIN| |00001670| 47 5f 53 51 55 41 52 45 | 53 3b 0d 0d 6c 6f 63 61 |G_SQUARE|S;..loca| |00001680| 6c 20 63 6f 6e 73 74 20 | 53 55 52 52 4f 55 4e 44 |l const |SURROUND| |00001690| 49 4e 47 5f 53 51 55 41 | 52 45 53 20 73 75 72 72 |ING_SQUA|RES surr| |000016a0| 6f 75 6e 64 69 6e 67 20 | 3d 0d 09 7b 0d 09 30 2c |ounding |=..{..0,| |000016b0| 30 2c 0d 09 30 2c 2d 31 | 2c 20 31 2c 2d 31 2c 20 |0,..0,-1|, 1,-1, | |000016c0| 31 2c 30 2c 20 31 2c 31 | 2c 20 30 2c 31 2c 20 2d |1,0, 1,1|, 0,1, -| |000016d0| 31 2c 31 2c 20 2d 31 2c | 30 2c 20 2d 31 2c 2d 31 |1,1, -1,|0, -1,-1| |000016e0| 2c 0d 09 30 2c 2d 32 2c | 20 31 2c 2d 32 2c 20 32 |,..0,-2,| 1,-2, 2| |000016f0| 2c 2d 32 2c 20 32 2c 2d | 31 2c 20 32 2c 30 2c 20 |,-2, 2,-|1, 2,0, | |00001700| 32 2c 31 2c 20 32 2c 32 | 2c 20 31 2c 32 2c 0d 09 |2,1, 2,2|, 1,2,..| |00001710| 30 2c 32 2c 20 2d 31 2c | 32 2c 20 2d 32 2c 32 2c |0,2, -1,|2, -2,2,| |00001720| 20 2d 32 2c 31 2c 20 2d | 32 2c 30 2c 20 2d 32 2c | -2,1, -|2,0, -2,| |00001730| 2d 31 2c 20 2d 32 2c 2d | 32 2c 20 2d 31 2c 20 2d |-1, -2,-|2, -1, -| |00001740| 32 0d 09 7d 3b 0d 0d 2f | 2f 20 2a 2a 2a 2a 2a 2a |2..};../|/ ******| |00001750| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********| |00001760| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********| |00001770| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********| |00001780| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********| |00001790| 2a 2a 2a 2a 2a 2a 0d 0d | 2f 2f 20 44 65 62 75 67 |******..|// Debug| |000017a0| 67 69 6e 67 20 6d 65 73 | 73 61 67 65 20 72 6f 75 |ging mes|sage rou| |000017b0| 74 69 6e 65 73 0d 0d 23 | 64 65 66 69 6e 65 20 45 |tines..#|define E| |000017c0| 58 50 4c 41 49 4e 5f 57 | 49 54 48 5f 4d 45 53 53 |XPLAIN_W|ITH_MESS| |000017d0| 41 47 45 53 20 30 0d 0d | 6c 6f 63 61 6c 20 76 6f |AGES 0..|local vo| |000017e0| 69 64 20 73 65 6e 64 6d | 65 73 73 61 67 65 28 75 |id sendm|essage(u| |000017f0| 5f 63 68 61 72 20 2a 6d | 73 67 29 0d 09 7b 0d 09 |_char *m|sg)..{..| |00001800| 69 6e 74 20 69 3b 09 2f | 2f 20 53 65 74 74 69 6e |int i;./|/ Settin| |00001810| 67 20 70 6c 61 79 65 72 | 20 62 69 74 73 20 74 6f |g player| bits to| |00001820| 20 61 6c 6c 20 7a 65 72 | 6f 20 6d 61 6b 65 73 20 | all zer|o makes | |00001830| 74 68 69 73 20 61 20 64 | 65 62 75 67 67 65 72 20 |this a d|ebugger | |00001840| 6d 65 73 73 61 67 65 0d | 09 66 6f 72 20 28 69 3d |message.|.for (i=| |00001850| 30 3b 20 69 3c 28 69 6e | 66 6f 2d 3e 6d 61 78 5f |0; i<(in|fo->max_| |00001860| 70 6c 61 79 65 72 73 2b | 33 31 29 2f 33 32 3b 20 |players+|31)/32; | |00001870| 69 2b 2b 29 20 69 6e 66 | 6f 2d 3e 6d 65 73 73 61 |i++) inf|o->messa| |00001880| 67 65 64 65 73 74 5b 69 | 5d 20 3d 20 30 3b 0d 09 |gedest[i|] = 0;..| |00001890| 66 6f 72 20 28 69 3d 30 | 3b 20 69 3c 3d 6d 73 67 |for (i=0|; i<=msg| |000018a0| 5b 30 5d 3b 20 69 2b 2b | 29 20 69 6e 66 6f 2d 3e |[0]; i++|) info->| |000018b0| 73 65 6e 64 6d 65 73 73 | 61 67 65 5b 69 5d 20 3d |sendmess|age[i] =| |000018c0| 20 6d 73 67 5b 69 5d 3b | 0d 09 7d 0d 0d 6c 6f 63 | msg[i];|..}..loc| |000018d0| 61 6c 20 76 6f 69 64 20 | 64 65 62 75 67 28 63 68 |al void |debug(ch| |000018e0| 61 72 20 2a 66 6f 72 6d | 61 74 2c 20 2e 2e 2e 29 |ar *form|at, ...)| |000018f0| 0d 09 7b 0d 09 75 6e 73 | 69 67 6e 65 64 20 63 68 |..{..uns|igned ch| |00001900| 61 72 20 62 75 66 66 65 | 72 5b 32 35 36 5d 3b 0d |ar buffe|r[256];.| |00001910| 09 76 61 5f 6c 69 73 74 | 20 70 74 72 3b 0d 09 76 |.va_list| ptr;..v| |00001920| 61 5f 73 74 61 72 74 28 | 70 74 72 2c 66 6f 72 6d |a_start(|ptr,form| |00001930| 61 74 29 3b 0d 09 62 75 | 66 66 65 72 5b 30 5d 20 |at);..bu|ffer[0] | |00001940| 3d 20 76 73 70 72 69 6e | 74 66 28 28 63 68 61 72 |= vsprin|tf((char| |00001950| 20 2a 29 62 75 66 66 65 | 72 2b 31 2c 20 66 6f 72 | *)buffe|r+1, for| |00001960| 6d 61 74 2c 20 70 74 72 | 29 3b 0d 09 76 61 5f 65 |mat, ptr|);..va_e| |00001970| 6e 64 28 70 74 72 29 3b | 0d 09 44 65 62 75 67 53 |nd(ptr);|..DebugS| |00001980| 74 72 28 62 75 66 66 65 | 72 29 3b 0d 09 7d 0d 0d |tr(buffe|r);..}..| |00001990| 6c 6f 63 61 6c 20 42 6f | 6f 6c 65 61 6e 20 53 61 |local Bo|olean Sa| |000019a0| 6d 65 53 74 72 69 6e 67 | 28 63 6f 6e 73 74 20 75 |meString|(const u| |000019b0| 6e 73 69 67 6e 65 64 20 | 63 68 61 72 20 2a 61 2c |nsigned |char *a,| |000019c0| 20 63 6f 6e 73 74 20 75 | 6e 73 69 67 6e 65 64 20 | const u|nsigned | |000019d0| 63 68 61 72 20 2a 62 29 | 0d 09 7b 0d 09 69 6e 74 |char *b)|..{..int| |000019e0| 20 69 3b 0d 09 66 6f 72 | 20 28 69 3d 30 3b 20 69 | i;..for| (i=0; i| |000019f0| 3c 3d 61 5b 30 5d 3b 20 | 69 2b 2b 29 20 69 66 20 |<=a[0]; |i++) if | |00001a00| 28 61 5b 69 5d 20 21 3d | 20 62 5b 69 5d 29 20 72 |(a[i] !=| b[i]) r| |00001a10| 65 74 75 72 6e 28 46 41 | 4c 53 45 29 3b 0d 09 72 |eturn(FA|LSE);..r| |00001a20| 65 74 75 72 6e 28 54 52 | 55 45 29 3b 0d 09 7d 0d |eturn(TR|UE);..}.| |00001a30| 0d 6c 6f 63 61 6c 20 76 | 6f 69 64 20 65 78 70 6c |.local v|oid expl| |00001a40| 61 69 6e 28 63 68 61 72 | 20 2a 66 6f 72 6d 61 74 |ain(char| *format| |00001a50| 2c 20 2e 2e 2e 29 0d 09 | 7b 0d 09 69 66 20 28 64 |, ...)..|{..if (d| |00001a60| 6f 5f 65 78 70 6c 61 69 | 6e 29 0d 09 09 7b 0d 09 |o_explai|n)...{..| |00001a70| 09 73 74 61 74 69 63 20 | 75 6e 73 69 67 6e 65 64 |.static |unsigned| |00001a80| 20 63 68 61 72 20 6f 6c | 64 5f 62 75 66 66 65 72 | char ol|d_buffer| |00001a90| 5b 32 35 36 5d 3b 0d 09 | 09 75 6e 73 69 67 6e 65 |[256];..|.unsigne| |00001aa0| 64 20 63 68 61 72 20 62 | 75 66 66 65 72 5b 32 35 |d char b|uffer[25| |00001ab0| 36 5d 3b 0d 09 09 76 61 | 5f 6c 69 73 74 20 70 74 |6];...va|_list pt| |00001ac0| 72 3b 0d 09 09 76 61 5f | 73 74 61 72 74 28 70 74 |r;...va_|start(pt| |00001ad0| 72 2c 66 6f 72 6d 61 74 | 29 3b 0d 09 09 62 75 66 |r,format|);...buf| |00001ae0| 66 65 72 5b 30 5d 20 3d | 20 76 73 70 72 69 6e 74 |fer[0] =| vsprint| |00001af0| 66 28 28 63 68 61 72 20 | 2a 29 62 75 66 66 65 72 |f((char |*)buffer| |00001b00| 2b 31 2c 20 66 6f 72 6d | 61 74 2c 20 70 74 72 29 |+1, form|at, ptr)| |00001b10| 3b 0d 09 09 76 61 5f 65 | 6e 64 28 70 74 72 29 3b |;...va_e|nd(ptr);| |00001b20| 0d 09 09 0d 23 69 66 20 | 45 58 50 4c 41 49 4e 5f |....#if |EXPLAIN_| |00001b30| 57 49 54 48 5f 4d 45 53 | 53 41 47 45 53 0d 09 09 |WITH_MES|SAGES...| |00001b40| 69 66 20 28 69 6e 66 6f | 2d 3e 73 65 6e 64 6d 65 |if (info|->sendme| |00001b50| 73 73 61 67 65 5b 30 5d | 20 3d 3d 20 30 20 26 26 |ssage[0]| == 0 &&| |00001b60| 20 21 53 61 6d 65 53 74 | 72 69 6e 67 28 62 75 66 | !SameSt|ring(buf| |00001b70| 66 65 72 2c 20 6f 6c 64 | 5f 62 75 66 66 65 72 29 |fer, old|_buffer)| |00001b80| 29 0d 09 09 09 7b 20 73 | 65 6e 64 6d 65 73 73 61 |)....{ s|endmessa| |00001b90| 67 65 28 62 75 66 66 65 | 72 29 3b 20 42 6c 6f 63 |ge(buffe|r); Bloc| |00001ba0| 6b 4d 6f 76 65 28 62 75 | 66 66 65 72 2c 20 6f 6c |kMove(bu|ffer, ol| |00001bb0| 64 5f 62 75 66 66 65 72 | 2c 20 31 2b 62 75 66 66 |d_buffer|, 1+buff| |00001bc0| 65 72 5b 30 5d 29 3b 20 | 7d 0d 23 65 6c 73 65 0d |er[0]); |}.#else.| |00001bd0| 09 09 69 66 20 28 21 53 | 61 6d 65 53 74 72 69 6e |..if (!S|ameStrin| |00001be0| 67 28 62 75 66 66 65 72 | 2c 20 6f 6c 64 5f 62 75 |g(buffer|, old_bu| |00001bf0| 66 66 65 72 29 29 0d 09 | 09 09 7b 0d 09 09 09 47 |ffer))..|..{....G| |00001c00| 72 61 66 50 74 72 20 6f | 6c 64 3b 0d 09 09 09 52 |rafPtr o|ld;....R| |00001c10| 67 6e 48 61 6e 64 6c 65 | 20 75 70 64 61 74 65 52 |gnHandle| updateR| |00001c20| 67 6e 20 3d 20 4e 65 77 | 52 67 6e 28 29 3b 0d 09 |gn = New|Rgn();..| |00001c30| 09 09 47 65 74 50 6f 72 | 74 28 26 6f 6c 64 29 3b |..GetPor|t(&old);| |00001c40| 0d 09 09 09 53 65 74 50 | 6f 72 74 28 64 65 62 75 |....SetP|ort(debu| |00001c50| 67 77 69 6e 64 6f 77 29 | 3b 0d 09 09 09 54 65 78 |gwindow)|;....Tex| |00001c60| 74 46 6f 6e 74 28 67 65 | 6e 65 76 61 29 3b 0d 09 |tFont(ge|neva);..| |00001c70| 09 09 54 65 78 74 53 69 | 7a 65 28 31 30 29 3b 0d |..TextSi|ze(10);.| |00001c80| 09 09 09 53 63 72 6f 6c | 6c 52 65 63 74 28 26 64 |...Scrol|lRect(&d| |00001c90| 65 62 75 67 77 69 6e 64 | 6f 77 2d 3e 70 6f 72 74 |ebugwind|ow->port| |00001ca0| 52 65 63 74 2c 20 30 2c | 20 2d 31 32 2c 20 75 70 |Rect, 0,| -12, up| |00001cb0| 64 61 74 65 52 67 6e 29 | 3b 0d 09 09 09 44 69 73 |dateRgn)|;....Dis| |00001cc0| 70 6f 73 65 52 67 6e 28 | 75 70 64 61 74 65 52 67 |poseRgn(|updateRg| |00001cd0| 6e 29 3b 0d 09 09 09 4d | 6f 76 65 54 6f 28 64 65 |n);....M|oveTo(de| |00001ce0| 62 75 67 77 69 6e 64 6f | 77 2d 3e 70 6f 72 74 52 |bugwindo|w->portR| |00001cf0| 65 63 74 2e 6c 65 66 74 | 20 2b 20 36 2c 20 64 65 |ect.left| + 6, de| |00001d00| 62 75 67 77 69 6e 64 6f | 77 2d 3e 70 6f 72 74 52 |bugwindo|w->portR| |00001d10| 65 63 74 2e 62 6f 74 74 | 6f 6d 20 2d 20 36 29 3b |ect.bott|om - 6);| |00001d20| 0d 09 09 09 44 72 61 77 | 53 74 72 69 6e 67 28 62 |....Draw|String(b| |00001d30| 75 66 66 65 72 29 3b 0d | 09 09 09 53 65 74 50 6f |uffer);.|...SetPo| |00001d40| 72 74 28 6f 6c 64 29 3b | 0d 09 09 09 42 6c 6f 63 |rt(old);|....Bloc| |00001d50| 6b 4d 6f 76 65 28 62 75 | 66 66 65 72 2c 20 6f 6c |kMove(bu|ffer, ol| |00001d60| 64 5f 62 75 66 66 65 72 | 2c 20 31 2b 62 75 66 66 |d_buffer|, 1+buff| |00001d70| 65 72 5b 30 5d 29 3b 0d | 09 09 09 7d 0d 23 65 6e |er[0]);.|...}.#en| |00001d80| 64 69 66 0d 09 09 7d 0d | 09 7d 0d 0d 2f 2f 20 2a |dif...}.|.}..// *| |00001d90| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********| |00001da0| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********| |00001db0| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********| |00001dc0| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********| |00001dd0| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 0d 0d 2f 2f 20 |********|***..// | |00001de0| 47 65 6e 65 72 61 6c 20 | 75 74 69 6c 69 74 79 20 |General |utility | |00001df0| 72 6f 75 74 69 6e 65 73 | 0d 0d 6c 6f 63 61 6c 20 |routines|..local | |00001e00| 54 45 52 52 41 49 4e 20 | 72 61 77 5f 67 65 74 6d |TERRAIN |raw_getm| |00001e10| 61 70 63 65 6c 6c 28 4d | 41 50 5f 58 20 78 2c 20 |apcell(M|AP_X x, | |00001e20| 4d 41 50 5f 59 20 79 29 | 0d 09 7b 0d 09 2f 2f 20 |MAP_Y y)|..{..// | |00001e30| 54 68 69 73 20 77 61 73 | 20 74 68 65 20 6f 6c 64 |This was| the old| |00001e40| 20 77 61 79 2c 20 77 68 | 65 6e 20 42 72 61 69 6e | way, wh|en Brain| |00001e50| 73 20 77 65 72 65 20 6a | 75 73 74 20 67 69 76 65 |s were j|ust give| |00001e60| 6e 20 61 20 73 6d 61 6c | 6c 20 73 71 75 61 72 65 |n a smal|l square| |00001e70| 20 6f 66 20 74 68 65 20 | 6d 61 70 0d 2f 2a 09 69 | of the |map./*.i| |00001e80| 66 20 28 78 20 3c 20 69 | 6e 66 6f 2d 3e 76 69 65 |f (x < i|nfo->vie| |00001e90| 77 5f 6c 65 66 74 20 7c | 7c 20 79 20 3c 20 69 6e |w_left ||| y < in| |00001ea0| 66 6f 2d 3e 76 69 65 77 | 5f 74 6f 70 29 20 72 65 |fo->view|_top) re| |00001eb0| 74 75 72 6e 28 44 45 45 | 50 53 45 41 29 3b 2a 2f |turn(DEE|PSEA);*/| |00001ec0| 0d 2f 2a 09 79 20 2d 3d | 20 69 6e 66 6f 2d 3e 76 |./*.y -=| info->v| |00001ed0| 69 65 77 5f 74 6f 70 3b | 2a 2f 0d 2f 2a 09 78 20 |iew_top;|*/./*.x | |00001ee0| 2d 3d 20 69 6e 66 6f 2d | 3e 76 69 65 77 5f 6c 65 |-= info-|>view_le| |00001ef0| 66 74 3b 2a 2f 0d 2f 2a | 09 69 66 20 28 78 20 3e |ft;*/./*|.if (x >| |00001f00| 3d 20 69 6e 66 6f 2d 3e | 76 69 65 77 5f 77 69 64 |= info->|view_wid| |00001f10| 74 68 20 7c 7c 20 79 20 | 3e 3d 20 69 6e 66 6f 2d |th || y |>= info-| |00001f20| 3e 76 69 65 77 5f 68 65 | 69 67 68 74 29 20 72 65 |>view_he|ight) re| |00001f30| 74 75 72 6e 28 44 45 45 | 50 53 45 41 29 3b 2a 2f |turn(DEE|PSEA);*/| |00001f40| 0d 2f 2a 09 72 65 74 75 | 72 6e 28 69 6e 66 6f 2d |./*.retu|rn(info-| |00001f50| 3e 76 69 65 77 64 61 74 | 61 5b 79 2a 69 6e 66 6f |>viewdat|a[y*info| |00001f60| 2d 3e 76 69 65 77 5f 77 | 69 64 74 68 20 2b 20 78 |->view_w|idth + x| |00001f70| 5d 29 3b 2a 2f 0d 0d 09 | 2f 2f 20 54 68 69 73 20 |]);*/...|// This | |00001f80| 69 73 20 74 68 65 20 6e | 65 77 20 77 61 79 2c 20 |is the n|ew way, | |00001f90| 6e 6f 77 20 74 68 61 74 | 20 42 72 61 69 6e 73 20 |now that| Brains | |00001fa0| 67 65 74 20 61 20 70 6f | 69 6e 74 65 72 20 74 6f |get a po|inter to| |00001fb0| 20 74 68 65 20 77 68 6f | 6c 65 20 77 6f 72 6c 64 | the who|le world| |00001fc0| 0d 09 72 65 74 75 72 6e | 28 69 6e 66 6f 2d 3e 74 |..return|(info->t| |00001fd0| 68 65 57 6f 72 6c 64 5b | 28 75 5f 73 68 6f 72 74 |heWorld[|(u_short| |00001fe0| 29 79 20 3c 3c 20 38 20 | 7c 20 78 5d 29 3b 0d 09 |)y << 8 || x]);..| |00001ff0| 7d 0d 0d 2f 2f 20 54 68 | 65 73 65 20 74 77 6f 20 |}..// Th|ese two | |00002000| 72 65 61 64 20 74 68 65 | 20 74 65 72 72 61 69 6e |read the| terrain| |00002010| 20 2f 20 63 68 65 63 6b | 20 66 6f 72 20 6d 69 6e | / check| for min| |00002020| 65 20 61 74 20 4d 41 50 | 20 63 6f 6f 72 64 69 6e |e at MAP| coordin| |00002030| 61 74 65 73 20 58 2c 59 | 0d 23 64 65 66 69 6e 65 |ates X,Y|.#define| |00002040| 20 67 65 74 6d 61 70 63 | 65 6c 6c 4d 28 58 2c 59 | getmapc|ellM(X,Y| |00002050| 29 20 28 72 61 77 5f 67 | 65 74 6d 61 70 63 65 6c |) (raw_g|etmapcel| |00002060| 6c 28 28 58 29 2c 28 59 | 29 29 20 26 20 54 45 52 |l((X),(Y|)) & TER| |00002070| 52 41 49 4e 5f 4d 41 53 | 4b 29 0d 23 64 65 66 69 |RAIN_MAS|K).#defi| |00002080| 6e 65 20 63 68 65 63 6b | 6d 69 6e 65 4d 28 58 2c |ne check|mineM(X,| |00002090| 59 29 20 20 28 72 61 77 | 5f 67 65 74 6d 61 70 63 |Y) (raw|_getmapc| |000020a0| 65 6c 6c 28 28 58 29 2c | 28 59 29 29 20 26 20 54 |ell((X),|(Y)) & T| |000020b0| 45 52 52 41 49 4e 5f 4d | 49 4e 45 29 0d 0d 2f 2f |ERRAIN_M|INE)..//| |000020c0| 20 54 68 65 73 65 20 74 | 77 6f 20 72 65 61 64 20 | These t|wo read | |000020d0| 74 68 65 20 74 65 72 72 | 61 69 6e 20 2f 20 63 68 |the terr|ain / ch| |000020e0| 65 63 6b 20 66 6f 72 20 | 6d 69 6e 65 20 61 74 20 |eck for |mine at | |000020f0| 57 4f 52 4c 44 20 63 6f | 6f 72 64 69 6e 61 74 65 |WORLD co|ordinate| |00002100| 73 20 58 2c 59 0d 23 64 | 65 66 69 6e 65 20 67 65 |s X,Y.#d|efine ge| |00002110| 74 6d 61 70 63 65 6c 6c | 57 28 58 2c 59 29 20 67 |tmapcell|W(X,Y) g| |00002120| 65 74 6d 61 70 63 65 6c | 6c 4d 28 28 58 29 3e 3e |etmapcel|lM((X)>>| |00002130| 38 2c 20 28 59 29 3e 3e | 38 29 0d 23 64 65 66 69 |8, (Y)>>|8).#defi| |00002140| 6e 65 20 63 68 65 63 6b | 6d 69 6e 65 57 28 58 2c |ne check|mineW(X,| |00002150| 59 29 20 20 63 68 65 63 | 6b 6d 69 6e 65 4d 28 28 |Y) chec|kmineM((| |00002160| 58 29 3e 3e 38 2c 20 28 | 59 29 3e 3e 38 29 0d 0d |X)>>8, (|Y)>>8)..| |00002170| 6c 6f 63 61 6c 20 75 5f | 6c 6f 6e 67 20 66 69 6e |local u_|long fin| |00002180| 64 72 61 6e 67 65 28 57 | 4f 52 4c 44 5f 58 20 78 |drange(W|ORLD_X x| |00002190| 31 2c 20 57 4f 52 4c 44 | 5f 59 20 79 31 2c 20 57 |1, WORLD|_Y y1, W| |000021a0| 4f 52 4c 44 5f 58 20 78 | 32 2c 20 57 4f 52 4c 44 |ORLD_X x|2, WORLD| |000021b0| 5f 59 20 79 32 29 0d 09 | 7b 0d 09 72 65 67 69 73 |_Y y2)..|{..regis| |000021c0| 74 65 72 20 6c 6f 6e 67 | 20 78 64 69 66 66 20 3d |ter long| xdiff =| |000021d0| 20 28 6c 6f 6e 67 29 78 | 31 20 2d 20 28 6c 6f 6e | (long)x|1 - (lon| |000021e0| 67 29 78 32 3b 0d 09 72 | 65 67 69 73 74 65 72 20 |g)x2;..r|egister | |000021f0| 6c 6f 6e 67 20 79 64 69 | 66 66 20 3d 20 28 6c 6f |long ydi|ff = (lo| |00002200| 6e 67 29 79 31 20 2d 20 | 28 6c 6f 6e 67 29 79 32 |ng)y1 - |(long)y2| |00002210| 3b 0d 09 72 65 74 75 72 | 6e 28 73 71 72 74 28 78 |;..retur|n(sqrt(x| |00002220| 64 69 66 66 2a 78 64 69 | 66 66 20 2b 20 79 64 69 |diff*xdi|ff + ydi| |00002230| 66 66 2a 79 64 69 66 66 | 29 29 3b 0d 09 7d 0d 0d |ff*ydiff|));..}..| |00002240| 23 64 65 66 69 6e 65 20 | 6f 62 6a 65 63 74 72 61 |#define |objectra| |00002250| 6e 67 65 5f 74 6f 5f 6d | 65 28 4f 42 29 20 66 69 |nge_to_m|e(OB) fi| |00002260| 6e 64 72 61 6e 67 65 28 | 28 4f 42 29 2d 3e 78 2c |ndrange(|(OB)->x,| |00002270| 20 28 4f 42 29 2d 3e 79 | 2c 20 69 6e 66 6f 2d 3e | (OB)->y|, info->| |00002280| 74 61 6e 6b 78 2c 20 69 | 6e 66 6f 2d 3e 74 61 6e |tankx, i|nfo->tan| |00002290| 6b 79 29 0d 0d 2f 2f 20 | 46 6f 72 20 4d 61 63 20 |ky)..// |For Mac | |000022a0| 66 69 78 65 64 20 70 6f | 69 6e 74 20 74 72 69 67 |fixed po|int trig| |000022b0| 20 72 6f 75 74 69 6e 65 | 73 2c 20 66 75 6c 6c 20 | routine|s, full | |000022c0| 63 69 72 63 6c 65 20 69 | 73 20 32 20 2a 20 50 49 |circle i|s 2 * PI| |000022d0| 20 2a 20 30 78 31 30 30 | 30 30 0d 2f 2f 20 57 65 | * 0x100|00.// We| |000022e0| 20 77 61 6e 74 20 66 75 | 6c 6c 20 63 69 72 63 6c | want fu|ll circl| |000022f0| 65 20 74 6f 20 62 65 20 | 30 78 31 30 30 2c 20 73 |e to be |0x100, s| |00002300| 6f 20 64 69 76 69 64 65 | 20 62 79 20 28 32 20 2a |o divide| by (2 *| |00002310| 20 50 49 20 2a 20 30 78 | 31 30 30 30 30 20 2f 20 | PI * 0x|10000 / | |00002320| 30 78 31 30 30 29 0d 2f | 2f 20 77 68 69 63 68 20 |0x100)./|/ which | |00002330| 69 73 20 31 36 30 38 20 | 69 6e 20 64 65 63 69 6d |is 1608 |in decim| |00002340| 61 6c 0d 23 64 65 66 69 | 6e 65 20 61 69 6d 28 58 |al.#defi|ne aim(X| |00002350| 2c 59 29 20 28 28 46 69 | 78 41 54 61 6e 32 28 2d |,Y) ((Fi|xATan2(-| |00002360| 28 59 29 2c 28 58 29 29 | 2f 31 36 30 38 29 20 26 |(Y),(X))|/1608) &| |00002370| 20 30 78 46 46 29 0d 0d | 2f 2f 20 73 69 6e 20 61 | 0xFF)..|// sin a| |00002380| 6e 64 20 63 6f 73 20 72 | 6f 75 74 69 6e 65 73 20 |nd cos r|outines | |00002390| 61 72 65 20 61 64 6a 75 | 73 74 65 64 20 74 6f 20 |are adju|sted to | |000023a0| 74 61 6b 65 20 61 6e 67 | 6c 65 73 20 69 6e 20 74 |take ang|les in t| |000023b0| 68 65 20 72 61 6e 67 65 | 20 30 2d 32 35 35 0d 2f |he range| 0-255./| |000023c0| 2f 20 61 6e 64 20 72 65 | 74 75 72 6e 20 72 65 74 |/ and re|turn ret| |000023d0| 75 72 6e 20 76 61 6c 75 | 65 73 20 69 6e 20 74 68 |urn valu|es in th| |000023e0| 65 20 72 61 6e 67 65 20 | 2b 2f 2d 31 32 38 0d 23 |e range |+/-128.#| |000023f0| 64 65 66 69 6e 65 20 73 | 69 6e 28 58 29 20 28 28 |define s|in(X) ((| |00002400| 73 68 6f 72 74 29 28 46 | 72 61 63 53 69 6e 28 28 |short)(F|racSin((| |00002410| 75 5f 63 68 61 72 29 28 | 58 29 2a 31 36 30 38 4c |u_char)(|X)*1608L| |00002420| 29 20 3e 3e 20 32 33 29 | 29 0d 23 64 65 66 69 6e |) >> 23)|).#defin| |00002430| 65 20 63 6f 73 28 58 29 | 20 28 28 73 68 6f 72 74 |e cos(X)| ((short| |00002440| 29 28 46 72 61 63 43 6f | 73 28 28 75 5f 63 68 61 |)(FracCo|s((u_cha| |00002450| 72 29 28 58 29 2a 31 36 | 30 38 4c 29 20 3e 3e 20 |r)(X)*16|08L) >> | |00002460| 32 33 29 29 0d 0d 6c 6f | 63 61 6c 20 4f 62 6a 65 |23))..lo|cal Obje| |00002470| 63 74 49 6e 66 6f 20 2a | 66 69 6e 64 5f 6f 62 6a |ctInfo *|find_obj| |00002480| 65 63 74 28 4f 42 4a 45 | 43 54 20 6f 62 74 79 70 |ect(OBJE|CT obtyp| |00002490| 65 2c 20 4d 41 50 5f 58 | 20 78 2c 20 4d 41 50 5f |e, MAP_X| x, MAP_| |000024a0| 59 20 79 29 0d 09 7b 0d | 09 4f 62 6a 65 63 74 49 |Y y)..{.|.ObjectI| |000024b0| 6e 66 6f 20 2a 6f 62 3b | 0d 09 57 4f 52 4c 44 5f |nfo *ob;|..WORLD_| |000024c0| 58 20 77 78 20 3d 20 28 | 57 4f 52 4c 44 5f 58 29 |X wx = (|WORLD_X)| |000024d0| 78 20 3c 3c 20 38 3b 0d | 09 57 4f 52 4c 44 5f 59 |x << 8;.|.WORLD_Y| |000024e0| 20 77 79 20 3d 20 28 57 | 4f 52 4c 44 5f 59 29 79 | wy = (W|ORLD_Y)y| |000024f0| 20 3c 3c 20 38 3b 0d 09 | 66 6f 72 20 28 6f 62 3d | << 8;..|for (ob=| |00002500| 26 69 6e 66 6f 2d 3e 6f | 62 6a 65 63 74 73 5b 30 |&info->o|bjects[0| |00002510| 5d 3b 20 6f 62 3c 26 69 | 6e 66 6f 2d 3e 6f 62 6a |]; ob<&i|nfo->obj| |00002520| 65 63 74 73 5b 69 6e 66 | 6f 2d 3e 6e 75 6d 5f 6f |ects[inf|o->num_o| |00002530| 62 6a 65 63 74 73 5d 3b | 20 6f 62 2b 2b 29 0d 09 |bjects];| ob++)..| |00002540| 09 69 66 20 28 6f 62 2d | 3e 6f 62 6a 65 63 74 20 |.if (ob-|>object | |00002550| 3d 3d 20 6f 62 74 79 70 | 65 20 26 26 20 6f 62 2d |== obtyp|e && ob-| |00002560| 3e 78 20 3d 3d 20 77 78 | 20 26 26 20 6f 62 2d 3e |>x == wx| && ob->| |00002570| 79 20 3d 3d 20 77 79 29 | 20 72 65 74 75 72 6e 28 |y == wy)| return(| |00002580| 6f 62 29 3b 0d 09 72 65 | 74 75 72 6e 28 4e 55 4c |ob);..re|turn(NUL| |00002590| 4c 29 3b 0d 09 7d 0d 0d | 2f 2f 20 2a 2a 2a 2a 2a |L);..}..|// *****| |000025a0| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********| |000025b0| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********| |000025c0| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********| |000025d0| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********| |000025e0| 2a 2a 2a 2a 2a 2a 2a 0d | 0d 2f 2f 20 53 68 6f 74 |*******.|.// Shot| |000025f0| 73 20 63 61 6e 27 74 20 | 70 61 73 73 20 74 68 72 |s can't |pass thr| |00002600| 6f 75 67 68 20 62 75 69 | 6c 64 69 6e 67 73 2c 20 |ough bui|ldings, | |00002610| 68 61 6c 66 20 62 75 69 | 6c 64 69 6e 67 73 20 6f |half bui|ldings o| |00002620| 72 20 70 69 6c 6c 62 6f | 78 65 73 0d 2f 2f 20 49 |r pillbo|xes.// I| |00002630| 66 20 77 65 20 61 72 65 | 20 63 68 61 73 69 6e 67 |f we are| chasing| |00002640| 20 74 61 6e 6b 2c 20 61 | 6c 73 6f 20 64 69 73 63 | tank, a|lso disc| |00002650| 6f 75 72 61 67 65 20 77 | 61 73 74 69 6e 67 20 73 |ourage w|asting s| |00002660| 68 6f 74 73 20 73 68 6f | 6f 74 69 6e 67 20 66 6f |hots sho|oting fo| |00002670| 72 65 73 74 0d 2f 2f 20 | 4d 65 6e 20 63 61 6e 6e |rest.// |Men cann| |00002680| 6f 74 20 72 75 6e 20 74 | 68 72 6f 75 67 68 20 62 |ot run t|hrough b| |00002690| 75 69 6c 64 69 6e 67 73 | 2c 20 68 61 6c 66 20 62 |uildings|, half b| |000026a0| 75 69 6c 64 69 6e 67 73 | 2c 20 70 69 6c 6c 62 6f |uildings|, pillbo| |000026b0| 78 65 73 2c 20 72 65 66 | 62 61 73 65 73 20 6f 72 |xes, ref|bases or| |000026c0| 20 77 61 74 65 72 2f 64 | 65 65 70 73 65 61 0d 6c | water/d|eepsea.l| |000026d0| 6f 63 61 6c 20 42 59 54 | 45 20 73 74 61 74 69 6f |ocal BYT|E statio| |000026e0| 6e 61 72 79 5f 74 61 72 | 67 65 74 5f 70 61 74 68 |nary_tar|get_path| |000026f0| 5b 4e 55 4d 5f 54 45 52 | 52 41 49 4e 53 5d 20 3d |[NUM_TER|RAINS] =| |00002700| 20 7b 20 35 2c 20 20 30 | 2c 20 20 30 2c 20 20 30 | { 5, 0|, 0, 0| |00002710| 2c 20 20 30 2c 20 20 31 | 2c 20 20 30 2c 20 20 30 |, 0, 1|, 0, 0| |00002720| 2c 20 20 34 2c 20 20 30 | 2c 20 20 30 2c 20 20 30 |, 4, 0|, 0, 0| |00002730| 2c 20 31 36 2c 20 39 39 | 20 7d 3b 0d 6c 6f 63 61 |, 16, 99| };.loca| |00002740| 6c 20 42 59 54 45 20 6d | 6f 76 69 6e 67 5f 74 61 |l BYTE m|oving_ta| |00002750| 72 67 65 74 5f 70 61 74 | 68 20 20 20 20 5b 4e 55 |rget_pat|h [NU| |00002760| 4d 5f 54 45 52 52 41 49 | 4e 53 5d 20 3d 20 7b 20 |M_TERRAI|NS] = { | |00002770| 35 2c 20 20 30 2c 20 20 | 30 2c 20 20 30 2c 20 20 |5, 0, |0, 0, | |00002780| 30 2c 20 20 34 2c 20 20 | 30 2c 20 20 30 2c 20 20 |0, 4, |0, 0, | |00002790| 34 2c 20 20 30 2c 20 20 | 30 2c 20 20 30 2c 20 31 |4, 0, |0, 0, 1| |000027a0| 36 2c 20 39 39 20 7d 3b | 0d 6c 6f 63 61 6c 20 42 |6, 99 };|.local B| |000027b0| 59 54 45 20 72 75 6e 6e | 69 6e 67 5f 6d 61 6e 5f |YTE runn|ing_man_| |000027c0| 70 61 74 68 20 20 20 20 | 20 20 5b 4e 55 4d 5f 54 |path | [NUM_T| |000027d0| 45 52 52 41 49 4e 53 5d | 20 3d 20 7b 20 39 39 2c |ERRAINS]| = { 99,| |000027e0| 20 39 39 2c 20 34 2c 20 | 20 34 2c 20 20 31 2c 20 | 99, 4, | 4, 1, | |000027f0| 20 32 2c 20 20 34 2c 20 | 20 31 2c 20 39 39 2c 20 | 2, 4, | 1, 99, | |00002800| 20 31 2c 20 39 39 2c 20 | 39 39 2c 20 39 39 2c 20 | 1, 99, |99, 99, | |00002810| 39 39 20 7d 3b 0d 0d 2f | 2f 20 72 65 74 75 72 6e |99 };../|/ return| |00002820| 73 20 7a 65 72 6f 20 69 | 66 20 74 68 65 72 65 20 |s zero i|f there | |00002830| 69 73 20 61 20 63 6c 65 | 61 72 20 73 74 72 61 69 |is a cle|ar strai| |00002840| 67 68 74 20 6c 69 6e 65 | 20 70 61 74 68 2c 20 66 |ght line| path, f| |00002850| 72 6f 6d 20 78 2c 79 2c | 20 61 63 72 6f 73 73 20 |rom x,y,| across | |00002860| 74 65 72 72 61 69 6e 0d | 2f 2f 20 73 70 65 63 69 |terrain.|// speci| |00002870| 66 69 65 64 20 62 79 20 | 74 65 72 72 61 69 6e 63 |fied by |terrainc| |00002880| 6f 73 74 73 2c 20 74 6f | 20 74 68 65 20 74 61 72 |osts, to| the tar| |00002890| 67 65 74 20 61 74 20 74 | 78 2c 74 79 2c 20 69 6e |get at t|x,ty, in| |000028a0| 20 61 74 20 6d 6f 73 74 | 20 6d 61 78 73 74 65 70 | at most| maxstep| |000028b0| 73 20 73 74 65 70 73 0d | 2f 2f 20 28 61 20 73 74 |s steps.|// (a st| |000028c0| 65 70 20 69 73 20 68 61 | 6c 66 20 61 20 6d 61 70 |ep is ha|lf a map| |000028d0| 20 73 71 75 61 72 65 29 | 0d 2f 2f 20 49 66 20 74 | square)|.// If t| |000028e0| 68 65 72 65 20 69 73 20 | 6e 6f 74 20 61 20 63 6c |here is |not a cl| |000028f0| 65 61 72 20 70 61 74 68 | 2c 20 74 68 65 6e 20 69 |ear path|, then i| |00002900| 74 20 72 65 74 75 72 6e | 73 20 74 68 65 20 63 6f |t return|s the co| |00002910| 73 74 2c 0d 2f 2f 20 6d | 65 61 73 75 72 65 64 20 |st,.// m|easured | |00002920| 69 6e 20 73 68 6f 74 73 | 20 66 6f 72 20 73 68 6f |in shots| for sho| |00002930| 6f 74 69 6e 67 20 70 61 | 74 68 73 2c 20 61 6e 64 |oting pa|ths, and| |00002940| 20 69 6e 20 74 69 6d 65 | 20 66 6f 72 20 6d 61 6e | in time| for man| |00002950| 20 70 61 74 68 73 0d 6c | 6f 63 61 6c 20 73 68 6f | paths.l|ocal sho| |00002960| 72 74 20 70 61 74 68 5f | 63 6f 73 74 28 57 4f 52 |rt path_|cost(WOR| |00002970| 4c 44 5f 58 20 78 2c 20 | 57 4f 52 4c 44 5f 59 20 |LD_X x, |WORLD_Y | |00002980| 79 2c 20 42 6f 6f 6c 65 | 61 6e 20 2a 74 65 72 72 |y, Boole|an *terr| |00002990| 61 69 6e 63 6f 73 74 73 | 2c 0d 09 57 4f 52 4c 44 |aincosts|,..WORLD| |000029a0| 5f 58 20 74 78 2c 20 57 | 4f 52 4c 44 5f 59 20 74 |_X tx, W|ORLD_Y t| |000029b0| 79 2c 20 57 4f 52 44 20 | 6d 61 78 73 74 65 70 73 |y, WORD |maxsteps| |000029c0| 29 0d 09 7b 0d 09 42 59 | 54 45 20 64 69 72 65 63 |)..{..BY|TE direc| |000029d0| 74 69 6f 6e 20 3d 20 61 | 69 6d 28 74 78 20 2d 20 |tion = a|im(tx - | |000029e0| 28 6c 6f 6e 67 29 78 2c | 20 74 79 20 2d 20 28 6c |(long)x,| ty - (l| |000029f0| 6f 6e 67 29 79 29 3b 0d | 09 4d 41 50 5f 58 20 6c |ong)y);.|.MAP_X l| |00002a00| 61 73 74 78 20 3d 20 30 | 2c 20 74 61 72 67 78 20 |astx = 0|, targx | |00002a10| 3d 20 74 78 3e 3e 38 3b | 0d 09 4d 41 50 5f 59 20 |= tx>>8;|..MAP_Y | |00002a20| 6c 61 73 74 79 20 3d 20 | 30 2c 20 74 61 72 67 79 |lasty = |0, targy| |00002a30| 20 3d 20 74 79 3e 3e 38 | 3b 0d 09 73 68 6f 72 74 | = ty>>8|;..short| |00002a40| 20 73 74 65 70 73 20 3d | 20 66 69 6e 64 72 61 6e | steps =| findran| |00002a50| 67 65 28 74 78 2c 20 74 | 79 2c 20 78 2c 20 79 29 |ge(tx, t|y, x, y)| |00002a60| 20 3e 3e 20 37 3b 09 2f | 2f 20 63 6f 75 6e 74 20 | >> 7;./|/ count | |00002a70| 69 6e 20 68 61 6c 66 2d | 73 71 75 61 72 65 20 73 |in half-|square s| |00002a80| 74 65 70 73 0d 09 2f 2f | 73 68 6f 72 74 20 63 6c |teps..//|short cl| |00002a90| 6f 73 65 73 74 5f 73 74 | 65 70 20 3d 20 30 3b 0d |osest_st|ep = 0;.| |00002aa0| 09 73 68 6f 72 74 20 63 | 6f 73 74 20 3d 20 30 3b |.short c|ost = 0;| |00002ab0| 0d 09 69 66 20 28 73 74 | 65 70 73 20 3e 20 6d 61 |..if (st|eps > ma| |00002ac0| 78 73 74 65 70 73 29 20 | 72 65 74 75 72 6e 28 30 |xsteps) |return(0| |00002ad0| 78 37 46 46 46 29 3b 0d | 0d 09 2f 2f 20 54 68 69 |x7FFF);.|..// Thi| |00002ae0| 73 20 66 69 72 73 74 20 | 73 74 65 70 20 69 73 20 |s first |step is | |00002af0| 74 6f 20 6d 61 6b 65 20 | 73 75 72 65 20 77 65 20 |to make |sure we | |00002b00| 73 6b 69 70 20 6f 76 65 | 72 20 74 68 65 20 69 6e |skip ove|r the in| |00002b10| 69 74 69 61 6c 20 73 71 | 75 61 72 65 2c 0d 09 2f |itial sq|uare,../| |00002b20| 2f 20 61 6e 64 20 64 6f | 6e 27 74 20 63 6f 75 6e |/ and do|n't coun| |00002b30| 74 20 61 20 63 6f 73 74 | 20 66 6f 72 20 69 74 0d |t a cost| for it.| |00002b40| 09 78 20 2b 3d 20 73 69 | 6e 28 64 69 72 65 63 74 |.x += si|n(direct| |00002b50| 69 6f 6e 29 3b 0d 09 79 | 20 2d 3d 20 63 6f 73 28 |ion);..y| -= cos(| |00002b60| 64 69 72 65 63 74 69 6f | 6e 29 3b 0d 0d 09 77 68 |directio|n);...wh| |00002b70| 69 6c 65 20 28 2d 2d 73 | 74 65 70 73 20 3e 20 30 |ile (--s|teps > 0| |00002b80| 29 0d 09 09 7b 0d 09 09 | 78 20 2b 3d 20 73 69 6e |)...{...|x += sin| |00002b90| 28 64 69 72 65 63 74 69 | 6f 6e 29 3b 0d 09 09 79 |(directi|on);...y| |00002ba0| 20 2d 3d 20 63 6f 73 28 | 64 69 72 65 63 74 69 6f | -= cos(|directio| |00002bb0| 6e 29 3b 0d 09 09 69 66 | 20 28 28 78 3e 3e 38 29 |n);...if| ((x>>8)| |00002bc0| 3d 3d 74 61 72 67 78 20 | 26 26 20 28 79 3e 3e 38 |==targx |&& (y>>8| |00002bd0| 29 3d 3d 74 61 72 67 79 | 29 20 62 72 65 61 6b 3b |)==targy|) break;| |00002be0| 09 09 2f 2f 20 4f 4b 2c | 20 72 65 61 63 68 65 64 |..// OK,| reached| |00002bf0| 20 74 61 72 67 65 74 0d | 09 09 69 66 20 28 28 78 | target.|..if ((x| |00002c00| 3e 3e 38 29 3d 3d 6c 61 | 73 74 78 20 26 26 20 28 |>>8)==la|stx && (| |00002c10| 79 3e 3e 38 29 3d 3d 6c | 61 73 74 79 29 20 63 6f |y>>8)==l|asty) co| |00002c20| 6e 74 69 6e 75 65 3b 09 | 2f 2f 20 73 61 6d 65 20 |ntinue;.|// same | |00002c30| 73 71 75 61 72 65 20 61 | 73 20 6c 61 73 74 20 74 |square a|s last t| |00002c40| 69 6d 65 20 2d 2d 20 73 | 6b 69 70 20 69 74 0d 09 |ime -- s|kip it..| |00002c50| 09 63 6f 73 74 20 2b 3d | 20 74 65 72 72 61 69 6e |.cost +=| terrain| |00002c60| 63 6f 73 74 73 5b 67 65 | 74 6d 61 70 63 65 6c 6c |costs[ge|tmapcell| |00002c70| 57 28 78 2c 79 29 5d 3b | 0d 09 09 7d 0d 09 72 65 |W(x,y)];|...}..re| |00002c80| 74 75 72 6e 28 63 6f 73 | 74 29 3b 0d 09 7d 0d 0d |turn(cos|t);..}..| |00002c90| 2f 2f 20 4d 61 6e 20 77 | 69 6c 6c 20 6e 6f 74 20 |// Man w|ill not | |00002ca0| 72 75 6e 20 6f 76 65 72 | 20 6d 6f 72 65 20 74 68 |run over| more th| |00002cb0| 61 6e 20 35 20 73 71 75 | 61 72 65 73 20 6f 66 20 |an 5 squ|ares of | |00002cc0| 72 75 62 62 6c 65 2c 20 | 6f 72 20 32 30 20 73 71 |rubble, |or 20 sq| |00002cd0| 75 61 72 65 73 20 6f 66 | 20 72 6f 61 64 0d 23 64 |uares of| road.#d| |00002ce0| 65 66 69 6e 65 20 4d 41 | 4e 5f 50 41 54 48 28 58 |efine MA|N_PATH(X| |00002cf0| 2c 59 29 20 28 70 61 74 | 68 5f 63 6f 73 74 28 69 |,Y) (pat|h_cost(i| |00002d00| 6e 66 6f 2d 3e 74 61 6e | 6b 78 2c 69 6e 66 6f 2d |nfo->tan|kx,info-| |00002d10| 3e 74 61 6e 6b 79 2c 72 | 75 6e 6e 69 6e 67 5f 6d |>tanky,r|unning_m| |00002d20| 61 6e 5f 70 61 74 68 2c | 28 58 29 2c 28 59 29 2c |an_path,|(X),(Y),| |00002d30| 30 78 37 46 46 46 29 20 | 3c 20 32 30 29 0d 0d 2f |0x7FFF) |< 20)../| |00002d40| 2f 20 4e 6f 74 65 2c 20 | 6d 75 73 74 20 61 73 73 |/ Note, |must ass| |00002d50| 75 6d 65 20 73 68 6f 74 | 73 20 43 41 4e 20 74 72 |ume shot|s CAN tr| |00002d60| 61 76 65 6c 20 6f 76 65 | 72 20 75 6e 6b 6e 6f 77 |avel ove|r unknow| |00002d70| 6e 20 74 65 72 72 61 69 | 6e 2c 20 6f 74 68 65 72 |n terrai|n, other| |00002d80| 77 69 73 65 2c 0d 2f 2f | 20 61 73 20 73 6f 6f 6e |wise,.//| as soon| |00002d90| 20 61 73 20 77 65 20 6c | 65 61 76 65 20 74 68 65 | as we l|eave the| |00002da0| 20 76 69 63 69 6e 69 74 | 79 20 6f 66 20 61 6e 20 | vicinit|y of an | |00002db0| 75 6e 73 61 66 65 20 62 | 61 73 65 2c 20 69 74 73 |unsafe b|ase, its| |00002dc0| 20 74 65 72 72 61 69 6e | 20 62 65 63 6f 6d 65 73 | terrain| becomes| |00002dd0| 0d 2f 2f 20 75 6e 6b 6e | 6f 77 6e 2c 20 61 6e 64 |.// unkn|own, and| |00002de0| 20 77 65 20 77 6f 75 6c | 64 20 69 6d 6d 65 64 69 | we woul|d immedi| |00002df0| 61 74 65 6c 79 20 72 65 | 74 75 72 6e 2c 20 61 73 |ately re|turn, as| |00002e00| 73 75 6d 69 6e 67 20 69 | 74 20 73 61 66 65 20 0d |suming i|t safe .| |00002e10| 6c 6f 63 61 6c 20 42 6f | 6f 6c 65 61 6e 20 73 61 |local Bo|olean sa| |00002e20| 66 65 5f 62 61 73 65 28 | 4f 62 6a 65 63 74 49 6e |fe_base(|ObjectIn| |00002e30| 66 6f 20 2a 62 61 73 65 | 29 0d 09 7b 0d 09 4f 62 |fo *base|)..{..Ob| |00002e40| 6a 65 63 74 49 6e 66 6f | 20 2a 6f 62 3b 0d 09 66 |jectInfo| *ob;..f| |00002e50| 6f 72 20 28 6f 62 3d 26 | 69 6e 66 6f 2d 3e 6f 62 |or (ob=&|info->ob| |00002e60| 6a 65 63 74 73 5b 30 5d | 3b 20 6f 62 3c 26 69 6e |jects[0]|; ob<&in| |00002e70| 66 6f 2d 3e 6f 62 6a 65 | 63 74 73 5b 69 6e 66 6f |fo->obje|cts[info| |00002e80| 2d 3e 6e 75 6d 5f 6f 62 | 6a 65 63 74 73 5d 3b 20 |->num_ob|jects]; | |00002e90| 6f 62 2b 2b 29 0d 09 09 | 69 66 20 28 6f 62 2d 3e |ob++)...|if (ob->| |00002ea0| 6f 62 6a 65 63 74 20 3d | 3d 20 4f 42 4a 45 43 54 |object =|= OBJECT| |00002eb0| 5f 50 49 4c 4c 42 4f 58 | 20 26 26 20 6f 62 2d 3e |_PILLBOX| && ob->| |00002ec0| 70 69 6c 6c 62 6f 78 5f | 73 74 72 65 6e 67 74 68 |pillbox_|strength| |00002ed0| 20 3e 20 30 20 26 26 20 | 28 6f 62 2d 3e 69 6e 66 | > 0 && |(ob->inf| |00002ee0| 6f 20 26 20 4f 42 4a 45 | 43 54 5f 48 4f 53 54 49 |o & OBJE|CT_HOSTI| |00002ef0| 4c 45 29 29 0d 09 09 09 | 69 66 20 28 70 61 74 68 |LE))....|if (path| |00002f00| 5f 63 6f 73 74 28 6f 62 | 2d 3e 78 2c 20 6f 62 2d |_cost(ob|->x, ob-| |00002f10| 3e 79 2c 20 73 74 61 74 | 69 6f 6e 61 72 79 5f 74 |>y, stat|ionary_t| |00002f20| 61 72 67 65 74 5f 70 61 | 74 68 2c 20 62 61 73 65 |arget_pa|th, base| |00002f30| 2d 3e 78 2c 20 62 61 73 | 65 2d 3e 79 2c 20 31 36 |->x, bas|e->y, 16| |00002f40| 29 20 3d 3d 20 30 29 0d | 09 09 09 09 72 65 74 75 |) == 0).|....retu| |00002f50| 72 6e 28 46 41 4c 53 45 | 29 3b 0d 09 72 65 74 75 |rn(FALSE|);..retu| |00002f60| 72 6e 28 54 52 55 45 29 | 3b 0d 09 7d 0d 0d 2f 2f |rn(TRUE)|;..}..//| |00002f70| 20 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a | *******|********| |00002f80| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********| |00002f90| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********| |00002fa0| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********| |00002fb0| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 0d 0d 2f |********|*****../| |00002fc0| 2f 20 52 6f 75 74 65 20 | 66 69 6e 64 69 6e 67 20 |/ Route |finding | |00002fd0| 72 6f 75 74 69 6e 65 73 | 0d 0d 23 64 65 66 69 6e |routines|..#defin| |00002fe0| 65 20 41 52 4d 4f 55 52 | 5f 55 4e 49 54 5f 43 4f |e ARMOUR|_UNIT_CO| |00002ff0| 53 54 20 38 09 2f 2f 20 | 54 68 65 20 61 72 6d 6f |ST 8.// |The armo| |00003000| 75 72 20 63 6f 73 74 20 | 73 63 61 6c 65 20 63 6f |ur cost |scale co| |00003010| 75 6e 74 73 20 65 69 67 | 68 74 68 73 20 6f 66 20 |unts eig|hths of | |00003020| 61 20 75 6e 69 74 20 6f | 66 20 74 61 6e 6b 20 61 |a unit o|f tank a| |00003030| 72 6d 6f 75 72 0d 23 64 | 65 66 69 6e 65 20 4d 41 |rmour.#d|efine MA| |00003040| 58 5f 54 49 4d 45 5f 43 | 4f 53 54 20 20 20 30 78 |X_TIME_C|OST 0x| |00003050| 46 46 46 46 0d 23 64 65 | 66 69 6e 65 20 4d 41 58 |FFFF.#de|fine MAX| |00003060| 5f 53 48 45 4c 4c 5f 43 | 4f 53 54 20 20 30 78 46 |_SHELL_C|OST 0xF| |00003070| 46 0d 23 64 65 66 69 6e | 65 20 4d 41 58 5f 41 52 |F.#defin|e MAX_AR| |00003080| 4d 4f 55 52 5f 43 4f 53 | 54 20 30 78 46 46 0d 23 |MOUR_COS|T 0xFF.#| |00003090| 64 65 66 69 6e 65 20 55 | 4e 4b 4e 4f 57 4e 5f 43 |define U|NKNOWN_C| |000030a0| 4f 53 54 20 20 20 20 30 | 78 46 46 46 46 0d 23 64 |OST 0|xFFFF.#d| |000030b0| 65 66 69 6e 65 20 4d 41 | 58 5f 43 4f 53 54 20 28 |efine MA|X_COST (| |000030c0| 55 4e 4b 4e 4f 57 4e 5f | 43 4f 53 54 2d 31 29 0d |UNKNOWN_|COST-1).| |000030d0| 0d 2f 2f 20 4e 6f 74 65 | 73 3a 0d 2f 2f 20 54 68 |.// Note|s:.// Th| |000030e0| 65 20 27 73 71 75 61 72 | 65 63 6f 73 74 27 20 61 |e 'squar|ecost' a| |000030f0| 72 72 61 79 20 68 6f 6c | 64 73 20 74 68 65 20 63 |rray hol|ds the c| |00003100| 6f 73 74 73 20 74 6f 20 | 72 65 61 63 68 20 74 68 |osts to |reach th| |00003110| 65 20 74 61 72 67 65 74 | 20 66 72 6f 6d 20 74 68 |e target| from th| |00003120| 65 20 67 69 76 65 6e 20 | 73 71 75 61 72 65 20 2d |e given |square -| |00003130| 2d 0d 2f 2f 20 69 74 20 | 66 6f 72 6d 73 20 61 20 |-.// it |forms a | |00003140| 66 69 65 6c 64 20 66 6f | 72 20 74 68 65 20 74 61 |field fo|r the ta| |00003150| 6e 6b 20 74 6f 20 66 6f | 6c 6c 6f 77 20 74 68 65 |nk to fo|llow the| |00003160| 20 73 74 65 65 70 65 73 | 74 20 67 72 61 64 69 65 | steepes|t gradie| |00003170| 6e 74 20 64 6f 77 6e 68 | 69 6c 6c 20 74 6f 20 69 |nt downh|ill to i| |00003180| 74 73 20 74 61 72 67 65 | 74 2e 0d 2f 2f 20 54 68 |ts targe|t..// Th| |00003190| 65 20 27 63 6f 73 74 27 | 20 76 61 6c 75 65 73 20 |e 'cost'| values | |000031a0| 69 6e 20 74 68 65 20 43 | 6f 73 74 50 6f 69 6e 74 |in the C|ostPoint| |000031b0| 73 20 61 72 65 20 74 68 | 69 73 20 63 6f 73 74 20 |s are th|is cost | |000031c0| 74 6f 20 72 65 61 63 68 | 20 74 68 65 20 64 65 73 |to reach| the des| |000031d0| 74 69 6e 61 74 69 6f 6e | 2c 20 50 4c 55 53 0d 2f |tination|, PLUS./| |000031e0| 2f 20 61 20 28 6d 6f 73 | 74 6c 79 29 20 63 6f 6e |/ a (mos|tly) con| |000031f0| 73 65 72 76 61 74 69 76 | 65 20 68 65 75 72 69 73 |servativ|e heuris| |00003200| 74 69 63 20 65 73 74 69 | 6d 61 74 69 6e 67 20 74 |tic esti|mating t| |00003210| 68 65 20 6d 69 6e 69 6d | 75 6d 20 63 6f 73 74 20 |he minim|um cost | |00003220| 66 6f 72 20 74 68 65 20 | 74 61 6e 6b 20 74 6f 20 |for the |tank to | |00003230| 67 65 74 0d 2f 2f 20 74 | 6f 20 74 68 69 73 20 73 |get.// t|o this s| |00003240| 71 75 61 72 65 20 66 72 | 6f 6d 20 69 74 73 20 63 |quare fr|om its c| |00003250| 75 72 72 65 6e 74 20 70 | 6f 73 69 74 69 6f 6e 2e |urrent p|osition.| |00003260| 20 54 68 69 73 20 68 65 | 75 72 69 73 74 69 63 20 | This he|uristic | |00003270| 68 65 6c 70 73 20 67 75 | 69 64 65 20 74 68 65 20 |helps gu|ide the | |00003280| 73 65 61 72 63 68 0d 2f | 2f 20 70 72 65 66 65 72 |search./|/ prefer| |00003290| 65 6e 74 69 61 6c 6c 79 | 20 74 6f 77 61 72 64 73 |entially| towards| |000032a0| 20 77 68 65 72 65 20 74 | 68 65 20 74 61 6e 6b 20 | where t|he tank | |000032b0| 69 73 20 6e 6f 77 2c 20 | 72 61 74 68 65 72 20 74 |is now, |rather t| |000032c0| 68 65 6e 20 69 6e 20 66 | 72 75 69 74 6c 65 73 73 |hen in f|ruitless| |000032d0| 20 64 69 72 65 63 74 69 | 6f 6e 73 0d 2f 2f 20 61 | directi|ons.// a| |000032e0| 77 61 79 20 66 72 6f 6d | 20 69 74 2e 0d 0d 74 79 |way from| it...ty| |000032f0| 70 65 64 65 66 20 73 74 | 72 75 63 74 09 09 09 2f |pedef st|ruct.../| |00003300| 2f 20 55 73 65 64 20 74 | 6f 20 66 69 6e 64 20 62 |/ Used t|o find b| |00003310| 65 73 74 20 72 6f 75 74 | 65 20 74 68 72 6f 75 67 |est rout|e throug| |00003320| 68 20 63 6f 73 74 20 61 | 72 72 61 79 0d 09 7b 0d |h cost a|rray..{.| |00003330| 09 75 5f 63 68 61 72 20 | 78 3b 09 09 09 2f 2f 20 |.u_char |x;...// | |00003340| 4c 6f 63 61 74 69 6f 6e | 20 69 6e 20 61 72 72 61 |Location| in arra| |00003350| 79 20 28 4e 4f 54 20 69 | 6e 20 4d 41 50 20 63 6f |y (NOT i|n MAP co| |00003360| 6f 72 64 69 6e 61 74 65 | 73 29 0d 09 75 5f 63 68 |ordinate|s)..u_ch| |00003370| 61 72 20 79 3b 0d 09 75 | 5f 73 68 6f 72 74 20 74 |ar y;..u|_short t| |00003380| 69 6d 65 3b 09 09 2f 2f | 20 54 69 6d 65 20 74 6f |ime;..//| Time to| |00003390| 20 72 65 61 63 68 20 64 | 65 73 74 69 6e 61 74 69 | reach d|estinati| |000033a0| 6f 6e 20 66 72 6f 6d 20 | 74 68 69 73 20 73 71 75 |on from |this squ| |000033b0| 61 72 65 0d 09 75 5f 63 | 68 61 72 20 73 68 65 6c |are..u_c|har shel| |000033c0| 6c 73 3b 09 09 2f 2f 20 | 53 68 65 6c 6c 73 20 72 |ls;..// |Shells r| |000033d0| 65 71 75 69 72 65 64 20 | 74 6f 20 72 65 61 63 68 |equired |to reach| |000033e0| 20 64 65 73 74 69 6e 61 | 74 69 6f 6e 20 66 72 6f | destina|tion fro| |000033f0| 6d 20 74 68 69 73 20 73 | 71 75 61 72 65 0d 09 75 |m this s|quare..u| |00003400| 5f 63 68 61 72 20 61 72 | 6d 6f 75 72 3b 09 09 2f |_char ar|mour;../| |00003410| 2f 20 41 72 6d 6f 75 72 | 20 72 65 71 75 69 72 65 |/ Armour| require| |00003420| 64 20 74 6f 20 72 65 61 | 63 68 20 64 65 73 74 69 |d to rea|ch desti| |00003430| 6e 61 74 69 6f 6e 20 66 | 72 6f 6d 20 74 68 69 73 |nation f|rom this| |00003440| 20 73 71 75 61 72 65 20 | 28 73 63 61 6c 65 64 29 | square |(scaled)| |00003450| 0d 09 75 5f 63 68 61 72 | 20 74 72 65 65 73 3b 0d |..u_char| trees;.| |00003460| 09 75 5f 63 68 61 72 20 | 73 70 61 72 65 3b 0d 09 |.u_char |spare;..| |00003470| 75 5f 63 68 61 72 20 77 | 61 74 65 72 3b 09 09 2f |u_char w|ater;../| |00003480| 2f 20 6e 75 6d 62 65 72 | 20 6f 66 20 73 71 75 61 |/ number| of squa| |00003490| 72 65 73 20 74 6f 20 62 | 65 20 73 70 65 6e 74 20 |res to b|e spent | |000034a0| 63 72 6f 73 73 69 6e 67 | 20 77 61 74 65 72 0d 09 |crossing| water..| |000034b0| 75 5f 63 68 61 72 20 64 | 65 65 70 73 65 61 3b 09 |u_char d|eepsea;.| |000034c0| 09 2f 2f 20 73 65 74 20 | 69 66 20 70 61 74 68 20 |.// set |if path | |000034d0| 77 69 6c 6c 20 63 72 6f | 73 73 20 64 65 65 70 20 |will cro|ss deep | |000034e0| 73 65 61 0d 09 75 5f 73 | 68 6f 72 74 20 63 6f 73 |sea..u_s|hort cos| |000034f0| 74 3b 09 09 2f 2f 20 4f | 76 65 72 61 6c 6c 20 27 |t;..// O|verall '| |00003500| 63 6f 73 74 27 20 65 73 | 74 69 6d 61 74 65 20 74 |cost' es|timate t| |00003510| 6f 20 72 65 61 63 68 20 | 64 65 73 74 69 6e 61 74 |o reach |destinat| |00003520| 69 6f 6e 20 76 69 61 20 | 74 68 69 73 20 73 71 75 |ion via |this squ| |00003530| 61 72 65 0d 09 7d 20 43 | 6f 73 74 50 6f 69 6e 74 |are..} C|ostPoint| |00003540| 3b 0d 0d 23 64 65 66 69 | 6e 65 20 43 4f 53 54 5f |;..#defi|ne COST_| |00003550| 53 45 41 52 43 48 5f 52 | 41 4e 47 45 20 31 34 0d |SEARCH_R|ANGE 14.| |00003560| 2f 2f 20 54 61 6e 6b 20 | 63 61 6e 20 73 65 65 20 |// Tank |can see | |00003570| 74 68 65 20 73 71 75 61 | 72 65 20 69 74 20 69 73 |the squa|re it is| |00003580| 20 6f 6e 2c 20 61 6e 64 | 20 75 70 20 74 6f 20 43 | on, and| up to C| |00003590| 4f 53 54 5f 53 45 41 52 | 43 48 5f 52 41 4e 47 45 |OST_SEAR|CH_RANGE| |000035a0| 0d 2f 2f 20 61 62 6f 76 | 65 2c 20 62 65 6c 6f 77 |.// abov|e, below| |000035b0| 20 61 6e 64 20 74 6f 20 | 65 69 74 68 65 72 20 73 | and to |either s| |000035c0| 69 64 65 20 6f 66 20 69 | 74 0d 0d 23 64 65 66 69 |ide of i|t..#defi| |000035d0| 6e 65 20 43 4f 53 54 5f | 41 52 52 41 59 5f 53 49 |ne COST_|ARRAY_SI| |000035e0| 5a 45 20 28 43 4f 53 54 | 5f 53 45 41 52 43 48 5f |ZE (COST|_SEARCH_| |000035f0| 52 41 4e 47 45 20 2b 20 | 31 20 2b 20 43 4f 53 54 |RANGE + |1 + COST| |00003600| 5f 53 45 41 52 43 48 5f | 52 41 4e 47 45 29 0d 23 |_SEARCH_|RANGE).#| |00003610| 64 65 66 69 6e 65 20 49 | 4e 5f 43 4f 53 54 41 52 |define I|N_COSTAR| |00003620| 52 41 59 28 58 29 20 28 | 28 42 59 54 45 29 28 58 |RAY(X) (|(BYTE)(X| |00003630| 29 20 3c 20 28 42 59 54 | 45 29 28 43 4f 53 54 5f |) < (BYT|E)(COST_| |00003640| 41 52 52 41 59 5f 53 49 | 5a 45 29 29 0d 0d 74 79 |ARRAY_SI|ZE))..ty| |00003650| 70 65 64 65 66 20 75 5f | 63 68 61 72 20 20 20 20 |pedef u_|char | |00003660| 20 75 5f 63 68 61 72 33 | 32 20 20 20 5b 33 32 5d | u_char3|2 [32]| |00003670| 3b 09 09 09 09 2f 2f 20 | 52 6f 77 20 6f 66 20 33 |;....// |Row of 3| |00003680| 32 20 75 6e 73 69 67 6e | 65 64 20 63 68 61 72 20 |2 unsign|ed char | |00003690| 76 61 6c 75 65 73 0d 74 | 79 70 65 64 65 66 20 75 |values.t|ypedef u| |000036a0| 5f 73 68 6f 72 74 20 20 | 20 20 75 5f 73 68 6f 72 |_short | u_shor| |000036b0| 74 33 32 20 20 5b 33 32 | 5d 3b 09 09 09 09 2f 2f |t32 [32|];....//| |000036c0| 20 52 6f 77 20 6f 66 20 | 33 32 20 75 6e 73 69 67 | Row of |32 unsig| |000036d0| 6e 65 64 20 73 68 6f 72 | 74 20 76 61 6c 75 65 73 |ned shor|t values| |000036e0| 0d 0d 6c 6f 63 61 6c 20 | 75 5f 63 68 61 72 33 32 |..local |u_char32| |000036f0| 20 20 70 69 6c 6c 63 6f | 76 65 72 61 67 65 5b 43 | pillco|verage[C| |00003700| 4f 53 54 5f 41 52 52 41 | 59 5f 53 49 5a 45 5d 3b |OST_ARRA|Y_SIZE];| |00003710| 09 2f 2f 20 41 72 72 61 | 79 20 6f 66 20 72 6f 77 |.// Arra|y of row| |00003720| 73 20 6f 66 20 70 69 6c | 6c 62 6f 78 20 66 69 72 |s of pil|lbox fir| |00003730| 65 20 63 6f 76 65 72 61 | 67 65 0d 6c 6f 63 61 6c |e covera|ge.local| |00003740| 20 75 5f 73 68 6f 72 74 | 33 32 20 73 71 75 61 72 | u_short|32 squar| |00003750| 65 63 6f 73 74 20 20 5b | 43 4f 53 54 5f 41 52 52 |ecost [|COST_ARR| |00003760| 41 59 5f 53 49 5a 45 5d | 3b 09 2f 2f 20 41 72 72 |AY_SIZE]|;.// Arr| |00003770| 61 79 20 6f 66 20 72 6f | 77 73 20 6f 66 20 63 6f |ay of ro|ws of co| |00003780| 73 74 20 76 61 6c 75 65 | 73 0d 6c 6f 63 61 6c 20 |st value|s.local | |00003790| 75 5f 73 68 6f 72 74 33 | 32 20 43 50 43 6f 73 74 |u_short3|2 CPCost| |000037a0| 20 20 20 20 20 20 5b 43 | 4f 53 54 5f 41 52 52 41 | [C|OST_ARRA| |000037b0| 59 5f 53 49 5a 45 5d 3b | 0d 0d 6c 6f 63 61 6c 20 |Y_SIZE];|..local | |000037c0| 6c 6f 6e 67 20 63 6f 73 | 74 61 72 72 61 79 5f 74 |long cos|tarray_t| |000037d0| 69 6d 65 3b 09 09 2f 2f | 20 74 69 6d 65 20 61 72 |ime;..//| time ar| |000037e0| 72 61 79 20 77 61 73 20 | 63 72 65 61 74 65 64 0d |ray was |created.| |000037f0| 2f 2f 20 70 6f 73 69 74 | 69 6f 6e 20 6f 66 20 61 |// posit|ion of a| |00003800| 72 72 61 79 20 6f 6e 20 | 6d 61 70 2c 20 70 6f 73 |rray on |map, pos| |00003810| 69 74 69 6f 6e 20 6f 66 | 20 74 61 72 67 65 74 20 |ition of| target | |00003820| 6f 6e 20 6d 61 70 2c 20 | 61 6e 64 0d 2f 2f 20 73 |on map, |and.// s| |00003830| 75 62 74 61 72 67 65 74 | 20 28 74 61 72 67 65 74 |ubtarget| (target| |00003840| 2c 20 6f 72 20 63 6c 6f | 73 65 73 74 20 70 6f 69 |, or clo|sest poi| |00003850| 6e 74 20 69 66 20 74 61 | 72 67 65 74 20 69 73 20 |nt if ta|rget is | |00003860| 6f 75 74 73 69 64 65 20 | 63 6f 73 74 61 72 72 61 |outside |costarra| |00003870| 79 29 0d 6c 6f 63 61 6c | 20 4d 41 50 5f 58 20 63 |y).local| MAP_X c| |00003880| 6f 73 74 61 72 72 61 79 | 5f 6c 65 66 74 2c 20 63 |ostarray|_left, c| |00003890| 6f 73 74 74 61 72 67 65 | 74 5f 78 2c 20 73 75 62 |osttarge|t_x, sub| |000038a0| 74 61 72 67 65 74 5f 78 | 3b 0d 6c 6f 63 61 6c 20 |target_x|;.local | |000038b0| 4d 41 50 5f 59 20 63 6f | 73 74 61 72 72 61 79 5f |MAP_Y co|starray_| |000038c0| 74 6f 70 2c 20 20 63 6f | 73 74 74 61 72 67 65 74 |top, co|sttarget| |000038d0| 5f 79 2c 20 73 75 62 74 | 61 72 67 65 74 5f 79 3b |_y, subt|arget_y;| |000038e0| 0d 6c 6f 63 61 6c 20 42 | 59 54 45 20 63 6f 73 74 |.local B|YTE cost| |000038f0| 61 72 72 61 79 5f 62 6f | 61 74 3b 09 09 2f 2f 20 |array_bo|at;..// | |00003900| 57 68 65 74 68 65 72 20 | 63 6f 73 74 61 72 72 61 |Whether |costarra| |00003910| 79 20 63 61 6c 63 75 6c | 61 74 65 64 20 66 6f 72 |y calcul|ated for| |00003920| 20 62 6f 61 74 20 6f 72 | 20 74 61 6e 6b 0d 6c 6f | boat or| tank.lo| |00003930| 63 61 6c 20 4f 42 4a 45 | 43 54 20 63 6f 73 74 61 |cal OBJE|CT costa| |00003940| 72 72 61 79 5f 74 61 72 | 67 3b 0d 6c 6f 63 61 6c |rray_tar|g;.local| |00003950| 20 75 5f 63 68 61 72 20 | 63 6f 73 74 61 72 72 61 | u_char |costarra| |00003960| 79 5f 74 61 6e 6b 68 69 | 74 73 3b 0d 2f 2f 20 48 |y_tankhi|ts;.// H| |00003970| 6f 77 20 6d 61 6e 79 20 | 70 69 6c 6c 62 6f 78 20 |ow many |pillbox | |00003980| 68 69 74 73 20 74 68 65 | 20 74 61 6e 6b 27 73 20 |hits the| tank's | |00003990| 63 75 72 72 65 6e 74 20 | 70 6f 73 69 74 69 6f 6e |current |position| |000039a0| 20 73 63 6f 72 65 73 2e | 20 4e 6f 72 6d 61 6c 6c | scores.| Normall| |000039b0| 79 20 61 20 74 77 6f 2d | 68 69 74 20 73 71 75 61 |y a two-|hit squa| |000039c0| 72 65 0d 2f 2f 20 69 73 | 20 62 61 64 20 6e 65 77 |re.// is| bad new| |000039d0| 73 2c 20 62 75 74 20 69 | 66 20 77 65 20 61 72 65 |s, but i|f we are| |000039e0| 20 61 6c 72 65 61 64 79 | 20 73 69 74 74 69 6e 67 | already| sitting| |000039f0| 20 6f 6e 20 61 20 74 68 | 72 65 65 2d 68 69 74 20 | on a th|ree-hit | |00003a00| 73 71 75 61 72 65 2c 20 | 74 68 65 6e 20 74 77 6f |square, |then two| |00003a10| 20 73 75 64 64 65 6e 6c | 79 0d 2f 2f 20 6c 6f 6f | suddenl|y.// loo| |00003a20| 6b 73 20 71 75 69 74 65 | 20 64 65 73 69 72 61 62 |ks quite| desirab| |00003a30| 6c 65 0d 6c 6f 63 61 6c | 20 42 59 54 45 20 63 61 |le.local| BYTE ca| |00003a40| 5f 74 61 6e 6b 78 2c 20 | 63 61 5f 74 61 6e 6b 79 |_tankx, |ca_tanky| |00003a50| 3b 09 2f 2f 20 50 6f 73 | 69 74 69 6f 6e 20 6f 66 |;.// Pos|ition of| |00003a60| 20 74 61 6e 6b 20 69 6e | 20 63 6f 73 74 61 72 72 | tank in| costarr| |00003a70| 61 79 20 63 6f 6f 72 64 | 69 6e 61 74 65 73 0d 0d |ay coord|inates..| |00003a80| 23 64 65 66 69 6e 65 20 | 4d 41 58 5f 48 45 41 50 |#define |MAX_HEAP| |00003a90| 5f 53 49 5a 45 20 32 30 | 30 0d 6c 6f 63 61 6c 20 |_SIZE 20|0.local | |00003aa0| 43 6f 73 74 50 6f 69 6e | 74 20 63 6f 73 74 5f 68 |CostPoin|t cost_h| |00003ab0| 65 61 70 5b 4d 41 58 5f | 48 45 41 50 5f 53 49 5a |eap[MAX_|HEAP_SIZ| |00003ac0| 45 5d 3b 09 2f 2f 20 53 | 6f 72 74 65 64 20 68 65 |E];.// S|orted he| |00003ad0| 61 70 20 6f 66 20 43 6f | 73 74 50 6f 69 6e 74 73 |ap of Co|stPoints| |00003ae0| 0d 6c 6f 63 61 6c 20 73 | 68 6f 72 74 20 68 65 61 |.local s|hort hea| |00003af0| 70 5f 73 69 7a 65 3d 30 | 3b 0d 0d 6c 6f 63 61 6c |p_size=0|;..local| |00003b00| 20 76 6f 69 64 20 73 68 | 6f 77 72 6f 75 74 65 28 | void sh|owroute(| |00003b10| 43 6f 73 74 50 6f 69 6e | 74 20 63 2c 20 75 5f 73 |CostPoin|t c, u_s| |00003b20| 68 6f 72 74 20 63 6f 6c | 6f 75 72 2c 20 75 5f 73 |hort col|our, u_s| |00003b30| 68 6f 72 74 20 73 68 6f | 74 70 6f 69 6e 74 29 0d |hort sho|tpoint).| |00003b40| 09 7b 0d 09 52 47 42 43 | 6f 6c 6f 72 20 63 6f 6c |.{..RGBC|olor col| |00003b50| 20 3d 20 7b 20 30 2c 20 | 30 2c 20 30 20 7d 3b 0d | = { 0, |0, 0 };.| |00003b60| 09 52 65 63 74 20 72 3b | 0d 09 75 5f 73 68 6f 72 |.Rect r;|..u_shor| |00003b70| 74 20 6c 6f 77 62 69 74 | 73 20 3d 20 28 63 6f 6c |t lowbit|s = (col| |00003b80| 6f 75 72 20 26 20 30 78 | 37 46 29 20 2a 20 30 78 |our & 0x|7F) * 0x| |00003b90| 31 38 30 20 2b 20 30 78 | 34 30 30 30 3b 0d 09 69 |180 + 0x|4000;..i| |00003ba0| 66 20 28 63 6f 6c 6f 75 | 72 20 2b 20 30 78 38 30 |f (colou|r + 0x80| |00003bb0| 20 26 20 30 78 30 38 30 | 29 20 63 6f 6c 2e 72 65 | & 0x080|) col.re| |00003bc0| 64 20 20 20 3d 20 6c 6f | 77 62 69 74 73 3b 0d 09 |d = lo|wbits;..| |00003bd0| 69 66 20 28 63 6f 6c 6f | 75 72 20 2b 20 30 78 38 |if (colo|ur + 0x8| |00003be0| 30 20 26 20 30 78 31 30 | 30 29 20 63 6f 6c 2e 67 |0 & 0x10|0) col.g| |00003bf0| 72 65 65 6e 20 3d 20 6c | 6f 77 62 69 74 73 3b 0d |reen = l|owbits;.| |00003c00| 09 69 66 20 28 63 6f 6c | 6f 75 72 20 2b 20 30 78 |.if (col|our + 0x| |00003c10| 38 30 20 26 20 30 78 32 | 30 30 29 20 63 6f 6c 2e |80 & 0x2|00) col.| |00003c20| 62 6c 75 65 20 20 3d 20 | 6c 6f 77 62 69 74 73 3b |blue = |lowbits;| |00003c30| 0d 09 52 47 42 46 6f 72 | 65 43 6f 6c 6f 72 28 26 |..RGBFor|eColor(&| |00003c40| 63 6f 6c 29 3b 0d 09 72 | 2e 74 6f 70 20 20 20 20 |col);..r|.top | |00003c50| 3d 20 63 2e 79 20 2a 20 | 38 3b 0d 09 72 2e 6c 65 |= c.y * |8;..r.le| |00003c60| 66 74 20 20 20 3d 20 63 | 2e 78 20 2a 20 38 3b 0d |ft = c|.x * 8;.| |00003c70| 09 72 2e 62 6f 74 74 6f | 6d 20 3d 20 72 2e 74 6f |.r.botto|m = r.to| |00003c80| 70 20 20 2b 20 38 3b 0d | 09 72 2e 72 69 67 68 74 |p + 8;.|.r.right| |00003c90| 20 20 3d 20 72 2e 6c 65 | 66 74 20 2b 20 38 3b 0d | = r.le|ft + 8;.| |00003ca0| 09 69 66 20 28 73 68 6f | 74 70 6f 69 6e 74 29 20 |.if (sho|tpoint) | |00003cb0| 49 6e 73 65 74 52 65 63 | 74 28 26 72 2c 20 31 2c |InsetRec|t(&r, 1,| |00003cc0| 20 31 29 3b 0d 09 50 61 | 69 6e 74 52 65 63 74 28 | 1);..Pa|intRect(| |00003cd0| 26 72 29 3b 0d 09 2f 2f | 64 65 62 75 67 28 22 25 |&r);..//|debug("%| |00003ce0| 64 2c 25 64 20 43 6f 73 | 74 20 25 58 20 52 65 61 |d,%d Cos|t %X Rea| |00003cf0| 6c 63 6f 73 74 20 25 58 | 22 2c 20 63 2e 78 2c 20 |lcost %X|", c.x, | |00003d00| 63 2e 79 2c 20 63 2e 63 | 6f 73 74 2c 20 63 6f 6c |c.y, c.c|ost, col| |00003d10| 6f 75 72 29 3b 0d 09 7d | 0d 0d 6c 6f 63 61 6c 20 |our);..}|..local | |00003d20| 76 6f 69 64 20 61 64 64 | 74 6f 68 65 61 70 28 69 |void add|toheap(i| |00003d30| 6e 74 20 70 6c 61 63 65 | 2c 20 43 6f 73 74 50 6f |nt place|, CostPo| |00003d40| 69 6e 74 20 6e 65 77 29 | 0d 09 7b 0d 09 69 6e 74 |int new)|..{..int| |00003d50| 20 70 61 72 65 6e 74 20 | 3d 20 28 70 6c 61 63 65 | parent |= (place| |00003d60| 2d 31 29 3e 3e 31 3b 0d | 09 63 6f 73 74 5f 68 65 |-1)>>1;.|.cost_he| |00003d70| 61 70 5b 70 6c 61 63 65 | 5d 3d 6e 65 77 3b 0d 09 |ap[place|]=new;..| |00003d80| 77 68 69 6c 65 20 28 70 | 6c 61 63 65 3e 30 20 26 |while (p|lace>0 &| |00003d90| 26 20 63 6f 73 74 5f 68 | 65 61 70 5b 70 61 72 65 |& cost_h|eap[pare| |00003da0| 6e 74 5d 2e 63 6f 73 74 | 20 3e 20 63 6f 73 74 5f |nt].cost| > cost_| |00003db0| 68 65 61 70 5b 70 6c 61 | 63 65 5d 2e 63 6f 73 74 |heap[pla|ce].cost| |00003dc0| 29 0d 09 09 7b 0d 09 09 | 43 6f 73 74 50 6f 69 6e |)...{...|CostPoin| |00003dd0| 74 20 74 65 6d 70 20 20 | 20 20 3d 20 63 6f 73 74 |t temp | = cost| |00003de0| 5f 68 65 61 70 5b 70 6c | 61 63 65 20 5d 3b 0d 09 |_heap[pl|ace ];..| |00003df0| 09 63 6f 73 74 5f 68 65 | 61 70 5b 70 6c 61 63 65 |.cost_he|ap[place| |00003e00| 20 5d 20 3d 20 63 6f 73 | 74 5f 68 65 61 70 5b 70 | ] = cos|t_heap[p| |00003e10| 61 72 65 6e 74 5d 3b 0d | 09 09 63 6f 73 74 5f 68 |arent];.|..cost_h| |00003e20| 65 61 70 5b 70 61 72 65 | 6e 74 5d 20 3d 20 74 65 |eap[pare|nt] = te| |00003e30| 6d 70 3b 0d 09 09 70 6c | 61 63 65 3d 70 61 72 65 |mp;...pl|ace=pare| |00003e40| 6e 74 3b 0d 09 09 70 61 | 72 65 6e 74 3d 28 70 6c |nt;...pa|rent=(pl| |00003e50| 61 63 65 2d 31 29 3e 3e | 31 3b 0d 09 09 7d 0d 09 |ace-1)>>|1;...}..| |00003e60| 7d 0d 0d 6c 6f 63 61 6c | 20 43 6f 73 74 50 6f 69 |}..local| CostPoi| |00003e70| 6e 74 20 72 65 6d 6f 76 | 65 66 72 6f 6d 68 65 61 |nt remov|efromhea| |00003e80| 70 28 76 6f 69 64 29 0d | 09 7b 0d 09 43 6f 73 74 |p(void).|.{..Cost| |00003e90| 50 6f 69 6e 74 20 74 6f | 70 20 3d 20 63 6f 73 74 |Point to|p = cost| |00003ea0| 5f 68 65 61 70 5b 30 5d | 3b 09 09 09 2f 2f 20 65 |_heap[0]|;...// e| |00003eb0| 78 74 72 61 63 74 20 74 | 6f 70 20 65 6c 65 6d 65 |xtract t|op eleme| |00003ec0| 6e 74 0d 09 69 6e 74 20 | 67 61 70 20 20 20 3d 20 |nt..int |gap = | |00003ed0| 30 3b 09 09 09 09 09 09 | 09 2f 2f 20 74 6f 70 20 |0;......|.// top | |00003ee0| 69 73 20 6e 6f 77 20 65 | 6d 70 74 79 0d 09 69 6e |is now e|mpty..in| |00003ef0| 74 20 6c 65 66 74 20 20 | 3d 20 31 3b 09 09 09 09 |t left |= 1;....| |00003f00| 09 09 09 2f 2f 20 4c 65 | 66 74 20 63 68 69 6c 64 |...// Le|ft child| |00003f10| 20 69 73 20 65 6c 65 6d | 65 6e 74 20 31 0d 09 69 | is elem|ent 1..i| |00003f20| 6e 74 20 72 69 67 68 74 | 20 3d 20 32 3b 09 09 09 |nt right| = 2;...| |00003f30| 09 09 09 09 2f 2f 20 52 | 69 67 68 74 20 63 68 69 |....// R|ight chi| |00003f40| 6c 64 20 69 73 20 65 6c | 65 6d 65 6e 74 20 32 0d |ld is el|ement 2.| |00003f50| 09 68 65 61 70 5f 73 69 | 7a 65 2d 2d 3b 09 09 09 |.heap_si|ze--;...| |00003f60| 09 09 09 09 2f 2f 20 57 | 65 20 68 61 76 65 20 72 |....// W|e have r| |00003f70| 65 6d 6f 76 65 64 20 6f | 6e 65 20 65 6c 65 6d 65 |emoved o|ne eleme| |00003f80| 6e 74 0d 09 77 68 69 6c | 65 28 6c 65 66 74 3c 3d |nt..whil|e(left<=| |00003f90| 68 65 61 70 5f 73 69 7a | 65 29 09 09 09 09 09 2f |heap_siz|e)...../| |00003fa0| 2f 20 6d 6f 76 65 20 67 | 61 70 20 74 6f 20 62 6f |/ move g|ap to bo| |00003fb0| 74 74 6f 6d 0d 09 09 7b | 0d 09 09 69 66 28 72 69 |ttom...{|...if(ri| |00003fc0| 67 68 74 3e 68 65 61 70 | 5f 73 69 7a 65 20 7c 7c |ght>heap|_size ||| |00003fd0| 20 63 6f 73 74 5f 68 65 | 61 70 5b 72 69 67 68 74 | cost_he|ap[right| |00003fe0| 5d 2e 63 6f 73 74 20 3e | 20 63 6f 73 74 5f 68 65 |].cost >| cost_he| |00003ff0| 61 70 5b 6c 65 66 74 5d | 2e 63 6f 73 74 29 0d 09 |ap[left]|.cost)..| |00004000| 09 09 7b 20 63 6f 73 74 | 5f 68 65 61 70 5b 67 61 |..{ cost|_heap[ga| |00004010| 70 5d 3d 63 6f 73 74 5f | 68 65 61 70 5b 6c 65 66 |p]=cost_|heap[lef| |00004020| 74 20 5d 3b 20 67 61 70 | 3d 6c 65 66 74 3b 20 20 |t ]; gap|=left; | |00004030| 7d 0d 09 09 65 6c 73 65 | 7b 20 63 6f 73 74 5f 68 |}...else|{ cost_h| |00004040| 65 61 70 5b 67 61 70 5d | 3d 63 6f 73 74 5f 68 65 |eap[gap]|=cost_he| |00004050| 61 70 5b 72 69 67 68 74 | 5d 3b 20 67 61 70 3d 72 |ap[right|]; gap=r| |00004060| 69 67 68 74 3b 20 7d 0d | 09 09 6c 65 66 74 20 20 |ight; }.|..left | |00004070| 3d 20 28 67 61 70 3c 3c | 31 29 2b 31 3b 0d 09 09 |= (gap<<|1)+1;...| |00004080| 72 69 67 68 74 20 3d 20 | 28 67 61 70 3c 3c 31 29 |right = |(gap<<1)| |00004090| 2b 32 3b 0d 09 09 7d 0d | 09 69 66 28 67 61 70 20 |+2;...}.|.if(gap | |000040a0| 21 3d 20 68 65 61 70 5f | 73 69 7a 65 29 20 61 64 |!= heap_|size) ad| |000040b0| 64 74 6f 68 65 61 70 28 | 67 61 70 2c 63 6f 73 74 |dtoheap(|gap,cost| |000040c0| 5f 68 65 61 70 5b 68 65 | 61 70 5f 73 69 7a 65 5d |_heap[he|ap_size]| |000040d0| 29 3b 0d 09 72 65 74 75 | 72 6e 28 74 6f 70 29 3b |);..retu|rn(top);| |000040e0| 09 09 09 09 09 09 09 2f | 2f 20 72 65 74 75 72 6e |......./|/ return| |000040f0| 20 65 78 74 72 61 63 74 | 65 64 20 65 6c 65 6d 65 | extract|ed eleme| |00004100| 6e 74 0d 09 7d 0d 0d 2f | 2f 20 4e 6f 74 65 3a 20 |nt..}../|/ Note: | |00004110| 74 68 65 20 63 6f 73 74 | 20 69 6e 20 74 68 65 20 |the cost| in the | |00004120| 43 6f 73 74 50 6f 69 6e | 74 20 69 73 20 62 69 61 |CostPoin|t is bia| |00004130| 73 65 64 20 77 69 74 68 | 20 74 68 65 20 73 65 61 |sed with| the sea| |00004140| 72 63 68 20 68 65 75 72 | 69 73 74 69 63 0d 2f 2f |rch heur|istic.//| |00004150| 20 72 65 61 6c 63 6f 73 | 74 20 69 73 20 74 68 65 | realcos|t is the| |00004160| 20 61 63 74 75 61 6c 20 | 63 6f 73 74 20 74 6f 20 | actual |cost to | |00004170| 72 65 61 63 68 20 74 68 | 65 20 64 65 73 74 69 6e |reach th|e destin| |00004180| 61 74 69 6f 6e 20 66 72 | 6f 6d 20 74 68 69 73 20 |ation fr|om this | |00004190| 70 6f 69 6e 74 0d 6c 6f | 63 61 6c 20 76 6f 69 64 |point.lo|cal void| |000041a0| 20 73 65 74 63 6f 73 74 | 28 43 6f 73 74 50 6f 69 | setcost|(CostPoi| |000041b0| 6e 74 20 63 2c 20 75 5f | 73 68 6f 72 74 20 72 65 |nt c, u_|short re| |000041c0| 61 6c 63 6f 73 74 29 0d | 09 7b 0d 09 69 6e 74 20 |alcost).|.{..int | |000041d0| 69 3b 0d 09 42 6f 6f 6c | 65 61 6e 20 61 6c 72 65 |i;..Bool|ean alre| |000041e0| 61 64 79 5f 70 72 65 73 | 65 6e 74 20 3d 20 28 43 |ady_pres|ent = (C| |000041f0| 50 43 6f 73 74 5b 63 2e | 79 5d 5b 63 2e 78 5d 20 |PCost[c.|y][c.x] | |00004200| 3c 20 55 4e 4b 4e 4f 57 | 4e 5f 43 4f 53 54 29 3b |< UNKNOW|N_COST);| |00004210| 0d 09 43 50 43 6f 73 74 | 5b 63 2e 79 5d 5b 63 2e |..CPCost|[c.y][c.| |00004220| 78 5d 20 20 20 20 20 3d | 20 63 2e 63 6f 73 74 3b |x] =| c.cost;| |00004230| 0d 09 73 71 75 61 72 65 | 63 6f 73 74 5b 63 2e 79 |..square|cost[c.y| |00004240| 5d 5b 63 2e 78 5d 20 3d | 20 72 65 61 6c 63 6f 73 |][c.x] =| realcos| |00004250| 74 3b 0d 0d 09 2f 2f 20 | 49 66 20 61 64 64 69 6e |t;...// |If addin| |00004260| 67 20 61 20 6d 61 78 63 | 6f 73 74 20 28 77 68 69 |g a maxc|ost (whi| |00004270| 63 68 20 62 79 20 64 65 | 66 69 6e 69 74 69 6f 6e |ch by de|finition| |00004280| 20 63 61 6e 6e 6f 74 20 | 61 6c 72 65 61 64 79 20 | cannot |already | |00004290| 62 65 20 70 72 65 73 65 | 6e 74 0d 09 2f 2f 20 62 |be prese|nt..// b| |000042a0| 65 63 61 75 73 65 20 74 | 68 65 72 65 20 69 73 20 |ecause t|here is | |000042b0| 6e 6f 20 70 72 65 2d 65 | 78 69 73 74 69 6e 67 20 |no pre-e|xisting | |000042c0| 63 6f 73 74 20 3e 20 4d | 41 58 5f 43 4f 53 54 29 |cost > M|AX_COST)| |000042d0| 20 74 68 65 6e 20 64 6f | 6e 27 74 20 62 6f 74 68 | then do|n't both| |000042e0| 65 72 0d 09 2f 2f 20 70 | 75 74 74 69 6e 67 20 69 |er..// p|utting i| |000042f0| 74 20 6f 6e 74 6f 20 74 | 68 65 20 68 65 61 70 20 |t onto t|he heap | |00004300| 28 6e 6f 20 70 6f 69 6e | 74 20 2d 2d 20 69 74 20 |(no poin|t -- it | |00004310| 63 61 6e 6e 6f 74 20 6c | 65 61 64 20 61 6e 79 77 |cannot l|ead anyw| |00004320| 68 65 72 65 29 0d 09 69 | 66 20 28 63 2e 63 6f 73 |here)..i|f (c.cos| |00004330| 74 20 3d 3d 20 4d 41 58 | 5f 43 4f 53 54 29 20 72 |t == MAX|_COST) r| |00004340| 65 74 75 72 6e 3b 0d 0d | 09 2f 2f 20 49 66 20 61 |eturn;..|.// If a| |00004350| 6c 72 65 61 64 79 20 70 | 72 65 73 65 6e 74 2c 20 |lready p|resent, | |00004360| 74 72 79 20 74 6f 20 66 | 69 6e 64 20 61 6e 64 20 |try to f|ind and | |00004370| 72 65 70 6c 61 63 65 20 | 74 68 65 20 65 6c 65 6d |replace |the elem| |00004380| 65 6e 74 20 69 6e 20 70 | 6c 61 63 65 20 69 6e 20 |ent in p|lace in | |00004390| 74 68 65 20 68 65 61 70 | 0d 09 69 66 20 28 61 6c |the heap|..if (al| |000043a0| 72 65 61 64 79 5f 70 72 | 65 73 65 6e 74 29 0d 09 |ready_pr|esent)..| |000043b0| 09 66 6f 72 20 28 69 3d | 30 3b 20 69 3c 68 65 61 |.for (i=|0; i<hea| |000043c0| 70 5f 73 69 7a 65 3b 20 | 69 2b 2b 29 0d 09 09 09 |p_size; |i++)....| |000043d0| 69 66 20 28 63 6f 73 74 | 5f 68 65 61 70 5b 69 5d |if (cost|_heap[i]| |000043e0| 2e 78 20 3d 3d 20 63 2e | 78 20 26 26 20 63 6f 73 |.x == c.|x && cos| |000043f0| 74 5f 68 65 61 70 5b 69 | 5d 2e 79 20 3d 3d 20 63 |t_heap[i|].y == c| |00004400| 2e 79 29 0d 09 09 09 09 | 7b 20 61 64 64 74 6f 68 |.y).....|{ addtoh| |00004410| 65 61 70 28 69 2c 20 63 | 29 3b 20 72 65 74 75 72 |eap(i, c|); retur| |00004420| 6e 3b 20 7d 0d 0d 09 2f | 2f 20 49 66 20 68 65 61 |n; }.../|/ If hea| |00004430| 70 20 61 6c 72 65 61 64 | 79 20 66 75 6c 6c 20 6e |p alread|y full n| |00004440| 75 6b 65 20 6c 61 73 74 | 20 65 6c 65 6d 65 6e 74 |uke last| element| |00004450| 20 28 73 68 6f 75 6c 64 | 6e 27 74 20 68 61 70 70 | (should|n't happ| |00004460| 65 6e 20 74 6f 6f 20 6f | 66 74 65 6e 29 0d 09 69 |en too o|ften)..i| |00004470| 66 20 28 68 65 61 70 5f | 73 69 7a 65 20 3e 3d 20 |f (heap_|size >= | |00004480| 4d 41 58 5f 48 45 41 50 | 5f 53 49 5a 45 29 20 68 |MAX_HEAP|_SIZE) h| |00004490| 65 61 70 5f 73 69 7a 65 | 2d 2d 3b 0d 09 61 64 64 |eap_size|--;..add| |000044a0| 74 6f 68 65 61 70 28 68 | 65 61 70 5f 73 69 7a 65 |toheap(h|eap_size| |000044b0| 2b 2b 2c 20 63 29 3b 0d | 09 7d 0d 0d 6c 6f 63 61 |++, c);.|.}..loca| |000044c0| 6c 20 75 5f 73 68 6f 72 | 74 20 72 6f 75 74 65 5f |l u_shor|t route_| |000044d0| 73 71 75 61 72 65 5f 74 | 69 6d 65 5f 63 6f 73 74 |square_t|ime_cost| |000044e0| 73 5b 4e 55 4d 5f 54 45 | 52 52 41 49 4e 53 5d 20 |s[NUM_TE|RRAINS] | |000044f0| 3d 0d 09 7b 0d 09 31 30 | 2c 20 31 2c 20 38 2c 20 |=..{..10|, 1, 8, | |00004500| 38 2c 09 2f 2f 20 42 55 | 49 4c 44 49 4e 47 2c 20 |8,.// BU|ILDING, | |00004510| 52 49 56 45 52 2c 20 53 | 57 41 4d 50 2c 20 43 52 |RIVER, S|WAMP, CR| |00004520| 41 54 45 52 0d 09 20 31 | 2c 20 33 2c 20 38 2c 20 |ATER.. 1|, 3, 8, | |00004530| 32 2c 09 2f 2f 20 52 4f | 41 44 2c 20 46 4f 52 45 |2,.// RO|AD, FORE| |00004540| 53 54 2c 20 52 55 42 42 | 4c 45 2c 20 47 52 41 53 |ST, RUBB|LE, GRAS| |00004550| 53 2c 0d 09 20 34 2c 20 | 31 2c 20 31 2c 20 31 2c |S,.. 4, |1, 1, 1,| |00004560| 09 2f 2f 20 48 41 4c 46 | 42 55 49 4c 44 49 4e 47 |.// HALF|BUILDING| |00004570| 2c 20 42 4f 41 54 2c 20 | 44 45 45 50 53 45 41 2c |, BOAT, |DEEPSEA,| |00004580| 20 52 45 46 42 41 53 45 | 5f 54 0d 09 31 30 30 30 | REFBASE|_T..1000| |00004590| 2c 20 31 30 30 30 09 09 | 2f 2f 20 50 49 4c 4c 42 |, 1000..|// PILLB| |000045a0| 4f 58 5f 54 2c 20 54 45 | 52 52 41 49 4e 5f 55 4e |OX_T, TE|RRAIN_UN| |000045b0| 4b 4e 4f 57 4e 0d 09 7d | 3b 0d 0d 2f 2f 20 65 78 |KNOWN..}|;..// ex| |000045c0| 61 6d 69 6e 65 20 73 71 | 75 61 72 65 20 69 6e 20 |amine sq|uare in | |000045d0| 43 6f 73 74 50 6f 69 6e | 74 20 63 2e 20 54 68 65 |CostPoin|t c. The| |000045e0| 20 63 6f 73 74 20 70 61 | 72 61 6d 65 74 65 72 73 | cost pa|rameters| |000045f0| 20 68 61 76 65 20 61 6c | 72 65 61 64 79 20 62 65 | have al|ready be| |00004600| 65 6e 0d 2f 2f 20 73 65 | 65 64 65 64 20 75 70 20 |en.// se|eded up | |00004610| 74 6f 20 74 68 69 73 20 | 70 6f 69 6e 74 20 2d 2d |to this |point --| |00004620| 20 74 68 65 20 63 75 72 | 72 65 6e 74 20 73 71 75 | the cur|rent squ| |00004630| 61 72 65 20 72 65 6d 61 | 69 6e 73 20 74 6f 20 62 |are rema|ins to b| |00004640| 65 20 61 64 64 65 64 2e | 0d 6c 6f 63 61 6c 20 76 |e added.|.local v| |00004650| 6f 69 64 20 65 78 61 6d | 69 6e 65 28 43 6f 73 74 |oid exam|ine(Cost| |00004660| 50 6f 69 6e 74 20 63 29 | 0d 09 7b 0d 09 69 66 20 |Point c)|..{..if | |00004670| 28 49 4e 5f 43 4f 53 54 | 41 52 52 41 59 28 63 2e |(IN_COST|ARRAY(c.| |00004680| 78 29 20 26 26 20 49 4e | 5f 43 4f 53 54 41 52 52 |x) && IN|_COSTARR| |00004690| 41 59 28 63 2e 79 29 29 | 0d 09 09 7b 0d 09 09 2f |AY(c.y))|...{.../| |000046a0| 2f 42 6f 6f 6c 65 61 6e | 20 65 78 61 6d 69 6e 69 |/Boolean| examini| |000046b0| 6e 67 5f 74 61 6e 6b 73 | 71 75 61 72 65 20 3d 20 |ng_tanks|quare = | |000046c0| 28 63 2e 78 20 3d 3d 20 | 63 61 5f 74 61 6e 6b 78 |(c.x == |ca_tankx| |000046d0| 20 26 26 20 63 2e 79 20 | 3d 3d 20 63 61 5f 74 61 | && c.y |== ca_ta| |000046e0| 6e 6b 79 29 3b 0d 09 09 | 4d 41 50 5f 58 20 78 20 |nky);...|MAP_X x | |000046f0| 3d 20 63 6f 73 74 61 72 | 72 61 79 5f 6c 65 66 74 |= costar|ray_left| |00004700| 20 2b 20 63 2e 78 3b 0d | 09 09 4d 41 50 5f 59 20 | + c.x;.|..MAP_Y | |00004710| 79 20 3d 20 63 6f 73 74 | 61 72 72 61 79 5f 74 6f |y = cost|array_to| |00004720| 70 20 20 2b 20 63 2e 79 | 3b 0d 09 09 75 5f 6c 6f |p + c.y|;...u_lo| |00004730| 6e 67 20 64 78 20 3d 20 | 61 62 73 28 28 6c 6f 6e |ng dx = |abs((lon| |00004740| 67 29 78 2d 28 6c 6f 6e | 67 29 6e 65 61 72 78 29 |g)x-(lon|g)nearx)| |00004750| 3b 0d 09 09 75 5f 6c 6f | 6e 67 20 64 79 20 3d 20 |;...u_lo|ng dy = | |00004760| 61 62 73 28 28 6c 6f 6e | 67 29 79 2d 28 6c 6f 6e |abs((lon|g)y-(lon| |00004770| 67 29 6e 65 61 72 79 29 | 3b 0d 09 09 75 5f 6c 6f |g)neary)|;...u_lo| |00004780| 6e 67 20 63 70 63 6f 73 | 74 2c 20 68 65 75 72 69 |ng cpcos|t, heuri| |00004790| 73 74 69 63 20 3d 20 6d | 61 78 28 64 78 2c 64 79 |stic = m|ax(dx,dy| |000047a0| 29 20 2b 20 6d 69 6e 28 | 64 78 2c 64 79 29 20 2f |) + min(|dx,dy) /| |000047b0| 20 32 3b 0d 09 09 54 45 | 52 52 41 49 4e 20 72 61 | 2;...TE|RRAIN ra| |000047c0| 77 20 3d 20 72 61 77 5f | 67 65 74 6d 61 70 63 65 |w = raw_|getmapce| |000047d0| 6c 6c 28 78 2c 79 29 3b | 0d 09 09 54 45 52 52 41 |ll(x,y);|...TERRA| |000047e0| 49 4e 20 74 20 20 20 3d | 20 72 61 77 20 26 20 54 |IN t =| raw & T| |000047f0| 45 52 52 41 49 4e 5f 4d | 41 53 4b 3b 0d 09 09 73 |ERRAIN_M|ASK;...s| |00004800| 68 6f 72 74 20 74 61 6e | 6b 73 68 65 6c 6c 73 20 |hort tan|kshells | |00004810| 3d 20 69 6e 66 6f 2d 3e | 73 68 65 6c 6c 73 3b 0d |= info->|shells;.| |00004820| 09 09 73 68 6f 72 74 20 | 74 61 6e 6b 61 72 6d 6f |..short |tankarmo| |00004830| 75 72 20 3d 20 69 6e 66 | 6f 2d 3e 61 72 6d 6f 75 |ur = inf|o->armou| |00004840| 72 20 2a 20 41 52 4d 4f | 55 52 5f 55 4e 49 54 5f |r * ARMO|UR_UNIT_| |00004850| 43 4f 53 54 3b 0d 09 09 | 73 68 6f 72 74 20 68 69 |COST;...|short hi| |00004860| 74 73 20 20 20 20 20 20 | 20 3d 20 70 69 6c 6c 63 |ts | = pillc| |00004870| 6f 76 65 72 61 67 65 5b | 63 2e 79 5d 5b 63 2e 78 |overage[|c.y][c.x| |00004880| 5d 3b 0d 09 09 6c 6f 6e | 67 20 20 6e 65 77 5f 74 |];...lon|g new_t| |00004890| 69 6d 65 63 6f 73 74 20 | 20 20 3d 20 63 2e 74 69 |imecost | = c.ti| |000048a0| 6d 65 20 2b 20 72 6f 75 | 74 65 5f 73 71 75 61 72 |me + rou|te_squar| |000048b0| 65 5f 74 69 6d 65 5f 63 | 6f 73 74 73 5b 74 5d 3b |e_time_c|osts[t];| |000048c0| 0d 09 09 73 68 6f 72 74 | 20 6e 65 77 5f 73 68 65 |...short| new_she| |000048d0| 6c 6c 63 6f 73 74 20 20 | 3d 20 63 2e 73 68 65 6c |llcost |= c.shel| |000048e0| 6c 73 3b 0d 09 09 73 68 | 6f 72 74 20 6e 65 77 5f |ls;...sh|ort new_| |000048f0| 61 72 6d 6f 75 72 63 6f | 73 74 20 3d 20 63 2e 61 |armourco|st = c.a| |00004900| 72 6d 6f 75 72 3b 0d 09 | 09 6c 6f 6e 67 20 6e 65 |rmour;..|.long ne| |00004910| 77 63 6f 73 74 20 3d 20 | 30 3b 0d 09 09 42 6f 6f |wcost = |0;...Boo| |00004920| 6c 65 61 6e 20 63 6f 75 | 6e 74 5f 63 6f 73 74 20 |lean cou|nt_cost | |00004930| 3d 20 54 52 55 45 3b 0d | 09 09 0d 09 09 2f 2f 20 |= TRUE;.|.....// | |00004940| 54 68 65 20 66 6f 6c 6c | 6f 77 69 6e 67 20 70 61 |The foll|owing pa| |00004950| 72 74 20 6f 66 20 74 68 | 65 20 63 6f 73 74 20 65 |rt of th|e cost e| |00004960| 76 61 6c 75 61 74 69 6f | 6e 20 69 73 20 73 6b 69 |valuatio|n is ski| |00004970| 70 70 65 64 20 69 66 20 | 77 65 20 61 72 65 3a 0d |pped if |we are:.| |00004980| 09 09 2f 2f 20 28 31 29 | 20 73 68 6f 6f 74 69 6e |..// (1)| shootin| |00004990| 67 20 73 6f 6d 65 74 68 | 69 6e 67 2c 20 61 6e 64 |g someth|ing, and| |000049a0| 0d 09 09 2f 2f 20 28 32 | 29 20 74 68 69 73 20 69 |...// (2|) this i| |000049b0| 73 20 61 20 6e 6f 74 20 | 62 6f 61 74 20 63 6f 73 |s a not |boat cos| |000049c0| 74 61 72 72 61 79 20 6f | 72 20 74 68 69 73 20 73 |tarray o|r this s| |000049d0| 71 75 61 72 65 20 69 73 | 20 6e 6f 74 20 77 61 74 |quare is| not wat| |000049e0| 65 72 2c 20 61 6e 64 0d | 09 09 2f 2f 20 28 33 29 |er, and.|..// (3)| |000049f0| 20 74 68 69 73 20 73 71 | 75 61 72 65 20 68 61 73 | this sq|uare has| |00004a00| 20 61 20 63 6c 65 61 72 | 20 70 61 74 68 20 74 6f | a clear| path to| |00004a10| 20 74 68 65 20 74 61 72 | 67 65 74 0d 09 09 2f 2f | the tar|get...//| |00004a20| 20 62 65 63 61 75 73 65 | 20 6f 6e 63 65 20 77 65 | because| once we| |00004a30| 20 68 61 76 65 20 61 20 | 76 61 6e 74 61 67 65 20 | have a |vantage | |00004a40| 70 6f 69 6e 74 20 74 6f | 20 73 68 6f 6f 74 0d 09 |point to| shoot..| |00004a50| 09 2f 2f 20 66 72 6f 6d | 2c 20 74 68 65 20 63 6f |.// from|, the co| |00004a60| 73 74 20 6f 66 20 67 6f | 69 6e 67 20 66 75 72 74 |st of go|ing furt| |00004a70| 68 65 72 20 69 73 20 69 | 72 72 65 6c 65 76 61 6e |her is i|rrelevan| |00004a80| 74 0d 09 09 69 66 20 28 | 63 6f 73 74 61 72 72 61 |t...if (|costarra| |00004a90| 79 5f 74 61 72 67 20 21 | 3d 20 53 48 4f 4f 54 5f |y_targ !|= SHOOT_| |00004aa0| 4e 4f 54 48 49 4e 47 20 | 26 26 20 28 21 63 6f 73 |NOTHING |&& (!cos| |00004ab0| 74 61 72 72 61 79 5f 62 | 6f 61 74 20 7c 7c 20 21 |tarray_b|oat || !| |00004ac0| 69 73 5f 77 65 74 28 74 | 29 29 29 0d 09 09 09 7b |is_wet(t|)))....{| |00004ad0| 0d 09 09 09 6c 6f 6e 67 | 20 63 6f 73 74 20 3d 20 |....long| cost = | |00004ae0| 70 61 74 68 5f 63 6f 73 | 74 28 28 57 4f 52 4c 44 |path_cos|t((WORLD| |00004af0| 5f 58 29 78 3c 3c 38 2c | 28 57 4f 52 4c 44 5f 59 |_X)x<<8,|(WORLD_Y| |00004b00| 29 79 3c 3c 38 2c 73 68 | 6f 6f 74 5f 70 61 74 68 |)y<<8,sh|oot_path| |00004b10| 5f 63 6f 73 74 73 2c 0d | 09 09 09 09 09 09 09 09 |_costs,.|........| |00004b20| 09 28 57 4f 52 4c 44 5f | 58 29 63 6f 73 74 74 61 |.(WORLD_|X)costta| |00004b30| 72 67 65 74 5f 78 3c 3c | 38 2c 28 57 4f 52 4c 44 |rget_x<<|8,(WORLD| |00004b40| 5f 59 29 63 6f 73 74 74 | 61 72 67 65 74 5f 79 3c |_Y)costt|arget_y<| |00004b50| 3c 38 2c 31 35 29 3b 0d | 09 09 09 69 66 20 28 63 |<8,15);.|...if (c| |00004b60| 6f 73 74 20 3d 3d 20 30 | 20 7c 7c 20 63 2e 73 68 |ost == 0| || c.sh| |00004b70| 65 6c 6c 73 20 2b 20 32 | 20 2a 20 63 6f 73 74 20 |ells + 2| * cost | |00004b80| 3c 20 69 6e 66 6f 2d 3e | 73 68 65 6c 6c 73 29 20 |< info->|shells) | |00004b90| 63 6f 75 6e 74 5f 63 6f | 73 74 20 3d 20 46 41 4c |count_co|st = FAL| |00004ba0| 53 45 3b 0d 09 09 09 7d | 0d 09 09 69 66 20 28 63 |SE;....}|...if (c| |00004bb0| 6f 75 6e 74 5f 63 6f 73 | 74 29 0d 09 09 09 7b 0d |ount_cos|t)....{.| |00004bc0| 09 09 09 6e 65 77 5f 61 | 72 6d 6f 75 72 63 6f 73 |...new_a|rmourcos| |00004bd0| 74 20 2b 3d 20 72 6f 75 | 74 65 5f 73 71 75 61 72 |t += rou|te_squar| |00004be0| 65 5f 74 69 6d 65 5f 63 | 6f 73 74 73 5b 74 5d 20 |e_time_c|osts[t] | |00004bf0| 2a 20 28 68 69 74 73 20 | 2d 20 63 6f 73 74 61 72 |* (hits |- costar| |00004c00| 72 61 79 5f 74 61 6e 6b | 68 69 74 73 29 3b 0d 09 |ray_tank|hits);..| |00004c10| 09 09 69 66 20 28 6e 65 | 77 5f 61 72 6d 6f 75 72 |..if (ne|w_armour| |00004c20| 63 6f 73 74 20 3c 20 30 | 29 20 6e 65 77 5f 61 72 |cost < 0|) new_ar| |00004c30| 6d 6f 75 72 63 6f 73 74 | 20 3d 20 30 3b 0d 09 09 |mourcost| = 0;...| |00004c40| 09 0d 09 09 09 69 66 20 | 28 74 20 3d 3d 20 44 45 |.....if |(t == DE| |00004c50| 45 50 53 45 41 29 20 63 | 2e 64 65 65 70 73 65 61 |EPSEA) c|.deepsea| |00004c60| 20 3d 20 54 52 55 45 3b | 0d 09 09 09 65 6c 73 65 | = TRUE;|....else| |00004c70| 20 69 66 20 28 74 20 3d | 3d 20 52 49 56 45 52 29 | if (t =|= RIVER)| |00004c80| 20 63 2e 77 61 74 65 72 | 2b 2b 3b 0d 09 09 09 65 | c.water|++;....e| |00004c90| 6c 73 65 20 69 66 20 28 | 74 20 3d 3d 20 42 55 49 |lse if (|t == BUI| |00004ca0| 4c 44 49 4e 47 29 0d 09 | 09 09 09 7b 0d 09 09 09 |LDING)..|...{....| |00004cb0| 09 69 66 20 28 74 61 6e | 6b 73 68 65 6c 6c 73 20 |.if (tan|kshells | |00004cc0| 3c 20 6e 65 77 5f 73 68 | 65 6c 6c 63 6f 73 74 2b |< new_sh|ellcost+| |00004cd0| 38 29 20 6e 65 77 63 6f | 73 74 20 3d 20 4d 41 58 |8) newco|st = MAX| |00004ce0| 5f 43 4f 53 54 3b 0d 09 | 09 09 09 65 6c 73 65 20 |_COST;..|...else | |00004cf0| 6e 65 77 5f 73 68 65 6c | 6c 63 6f 73 74 20 2b 3d |new_shel|lcost +=| |00004d00| 20 35 3b 0d 09 09 09 09 | 7d 0d 09 09 09 65 6c 73 | 5;.....|}....els| |00004d10| 65 20 69 66 20 28 74 20 | 3d 3d 20 48 41 4c 46 42 |e if (t |== HALFB| |00004d20| 55 49 4c 44 49 4e 47 29 | 0d 09 09 09 09 7b 0d 09 |UILDING)|.....{..| |00004d30| 09 09 09 69 66 20 28 74 | 61 6e 6b 73 68 65 6c 6c |...if (t|ankshell| |00004d40| 73 20 3c 20 6e 65 77 5f | 73 68 65 6c 6c 63 6f 73 |s < new_|shellcos| |00004d50| 74 2b 34 29 20 6e 65 77 | 63 6f 73 74 20 3d 20 4d |t+4) new|cost = M| |00004d60| 41 58 5f 43 4f 53 54 3b | 0d 09 09 09 09 65 6c 73 |AX_COST;|.....els| |00004d70| 65 20 6e 65 77 5f 73 68 | 65 6c 6c 63 6f 73 74 20 |e new_sh|ellcost | |00004d80| 2b 3d 20 34 3b 0d 09 09 | 09 09 7d 0d 09 09 09 65 |+= 4;...|..}....e| |00004d90| 6c 73 65 20 69 66 20 28 | 74 20 3d 3d 20 52 45 46 |lse if (|t == REF| |00004da0| 42 41 53 45 5f 54 29 0d | 09 09 09 09 7b 0d 09 09 |BASE_T).|....{...| |00004db0| 09 09 4f 62 6a 65 63 74 | 49 6e 66 6f 20 2a 6f 62 |..Object|Info *ob| |00004dc0| 20 3d 20 66 69 6e 64 5f | 6f 62 6a 65 63 74 28 4f | = find_|object(O| |00004dd0| 42 4a 45 43 54 5f 52 45 | 46 42 41 53 45 2c 78 2c |BJECT_RE|FBASE,x,| |00004de0| 79 29 3b 0d 09 09 09 09 | 69 66 20 28 6f 62 20 26 |y);.....|if (ob &| |00004df0| 26 20 6f 62 2d 3e 69 6e | 66 6f 20 26 20 4f 42 4a |& ob->in|fo & OBJ| |00004e00| 45 43 54 5f 48 4f 53 54 | 49 4c 45 29 20 6e 65 77 |ECT_HOST|ILE) new| |00004e10| 63 6f 73 74 20 3d 20 4d | 41 58 5f 43 4f 53 54 3b |cost = M|AX_COST;| |00004e20| 0d 09 09 09 09 7d 0d 09 | 09 0d 09 09 09 69 66 20 |.....}..|.....if | |00004e30| 28 72 61 77 20 26 20 54 | 45 52 52 41 49 4e 5f 4d |(raw & T|ERRAIN_M| |00004e40| 49 4e 45 29 0d 09 09 09 | 09 7b 0d 09 09 09 09 2f |INE)....|.{...../| |00004e50| 2f 20 49 66 20 63 6c 65 | 61 72 69 6e 67 20 6d 69 |/ If cle|aring mi| |00004e60| 6e 65 73 20 61 6e 64 20 | 77 65 20 68 61 76 65 20 |nes and |we have | |00004e70| 65 6e 6f 75 67 68 20 73 | 68 65 6c 6c 73 20 66 72 |enough s|hells fr| |00004e80| 65 65 2c 0d 09 09 09 09 | 2f 2f 20 63 6f 75 6e 74 |ee,.....|// count| |00004e90| 20 73 6f 6d 65 20 74 69 | 6d 65 20 61 6e 64 20 6f | some ti|me and o| |00004ea0| 6e 65 20 73 68 65 6c 6c | 2c 20 65 6c 73 65 20 63 |ne shell|, else c| |00004eb0| 6f 75 6e 74 20 6f 6e 65 | 20 61 72 6d 6f 75 72 20 |ount one| armour | |00004ec0| 68 69 74 0d 09 09 09 09 | 69 66 20 28 73 2e 63 6c |hit.....|if (s.cl| |00004ed0| 65 61 72 6d 69 6e 65 73 | 20 26 26 20 74 61 6e 6b |earmines| && tank| |00004ee0| 73 68 65 6c 6c 73 20 3e | 20 6e 65 77 5f 73 68 65 |shells >| new_she| |00004ef0| 6c 6c 63 6f 73 74 20 2b | 20 34 29 0d 09 09 09 09 |llcost +| 4).....| |00004f00| 09 7b 20 6e 65 77 5f 74 | 69 6d 65 63 6f 73 74 20 |.{ new_t|imecost | |00004f10| 2b 3d 20 38 3b 20 6e 65 | 77 5f 73 68 65 6c 6c 63 |+= 8; ne|w_shellc| |00004f20| 6f 73 74 2b 2b 3b 20 7d | 0d 09 09 09 09 65 6c 73 |ost++; }|.....els| |00004f30| 65 20 6e 65 77 5f 61 72 | 6d 6f 75 72 63 6f 73 74 |e new_ar|mourcost| |00004f40| 20 2b 3d 20 33 20 2a 20 | 41 52 4d 4f 55 52 5f 55 | += 3 * |ARMOUR_U| |00004f50| 4e 49 54 5f 43 4f 53 54 | 3b 0d 09 09 09 09 7d 0d |NIT_COST|;.....}.| |00004f60| 09 09 09 0d 09 09 09 2f | 2f 20 4e 6f 74 65 3a 20 |......./|/ Note: | |00004f70| 73 75 62 74 6c 65 20 73 | 74 75 66 66 20 68 65 72 |subtle s|tuff her| |00004f80| 65 2e 20 54 68 65 20 27 | 63 6f 73 74 27 20 6f 66 |e. The '|cost' of| |00004f90| 20 77 61 74 65 72 20 69 | 73 20 63 61 72 72 69 65 | water i|s carrie| |00004fa0| 64 20 75 6e 72 65 73 6f | 6c 76 65 64 2c 0d 09 09 |d unreso|lved,...| |00004fb0| 09 2f 2f 20 6c 69 6b 65 | 20 61 20 71 75 61 6e 74 |.// like| a quant| |00004fc0| 75 6d 20 73 75 70 65 72 | 70 6f 73 69 74 69 6f 6e |um super|position| |00004fd0| 20 6f 66 20 74 77 6f 20 | 64 69 66 66 65 72 65 6e | of two |differen| |00004fe0| 74 20 73 74 61 74 65 73 | 2c 20 75 6e 74 69 6c 20 |t states|, until | |00004ff0| 74 68 65 20 73 65 61 72 | 63 68 0d 09 09 09 2f 2f |the sear|ch....//| |00005000| 20 70 61 73 73 65 73 20 | 62 61 63 6b 20 6f 6e 74 | passes |back ont| |00005010| 6f 20 6c 61 6e 64 2c 20 | 77 68 65 72 65 20 74 68 |o land, |where th| |00005020| 65 20 63 6f 73 74 20 69 | 73 20 64 65 74 65 72 6d |e cost i|s determ| |00005030| 69 6e 65 64 20 64 65 70 | 65 6e 64 69 6e 67 20 6f |ined dep|ending o| |00005040| 6e 20 77 68 65 74 68 65 | 72 0d 09 09 09 2f 2f 20 |n whethe|r....// | |00005050| 74 68 65 20 70 61 74 68 | 20 66 72 6f 6d 20 74 68 |the path| from th| |00005060| 65 20 6c 61 6e 64 20 69 | 73 20 76 69 61 20 61 20 |e land i|s via a | |00005070| 62 6f 61 74 20 6f 72 20 | 6e 6f 74 2c 20 6c 69 6b |boat or |not, lik| |00005080| 65 20 61 20 71 75 61 6e | 74 75 6d 20 77 61 76 65 |e a quan|tum wave| |00005090| 20 63 6f 6c 6c 61 70 73 | 65 2e 0d 09 09 09 2f 2f | collaps|e.....//| |000050a0| 20 54 68 65 20 77 61 76 | 65 20 63 6f 6c 6c 61 70 | The wav|e collap| |000050b0| 73 65 20 63 61 6e 20 61 | 6c 73 6f 20 62 65 20 63 |se can a|lso be c| |000050c0| 61 75 73 65 64 20 62 79 | 20 74 68 65 20 74 61 6e |aused by| the tan| |000050d0| 6b 20 67 65 74 74 69 6e | 67 20 73 68 6f 74 2e 0d |k gettin|g shot..| |000050e0| 09 09 09 2f 2f 20 49 66 | 20 74 68 65 20 74 61 6e |...// If| the tan| |000050f0| 6b 20 69 73 20 61 6c 72 | 65 61 64 79 20 69 6e 20 |k is alr|eady in | |00005100| 77 61 74 65 72 2c 20 74 | 68 65 6e 20 77 65 20 70 |water, t|hen we p| |00005110| 72 65 74 65 6e 64 20 69 | 74 20 69 73 20 6f 6e 20 |retend i|t is on | |00005120| 61 20 6c 69 74 74 6c 65 | 20 73 71 75 61 72 65 0d |a little| square.| |00005130| 09 09 09 2f 2f 20 6f 66 | 20 6c 61 6e 64 2c 20 69 |...// of| land, i| |00005140| 6e 20 6f 72 64 65 72 20 | 74 6f 20 70 72 65 63 69 |n order |to preci| |00005150| 70 69 74 61 74 65 20 74 | 68 61 74 20 77 61 76 65 |pitate t|hat wave| |00005160| 20 63 6f 6c 6c 61 70 73 | 65 20 61 6e 64 20 67 65 | collaps|e and ge| |00005170| 74 20 74 68 65 20 72 69 | 67 68 74 20 61 6e 73 77 |t the ri|ght answ| |00005180| 65 72 0d 09 09 09 69 66 | 20 28 63 2e 78 20 3d 3d |er....if| (c.x ==| |00005190| 20 63 61 5f 74 61 6e 6b | 78 20 26 26 20 63 2e 79 | ca_tank|x && c.y| |000051a0| 20 3d 3d 20 63 61 5f 74 | 61 6e 6b 79 20 26 26 20 | == ca_t|anky && | |000051b0| 21 63 6f 73 74 61 72 72 | 61 79 5f 62 6f 61 74 29 |!costarr|ay_boat)| |000051c0| 20 74 20 3d 20 52 4f 41 | 44 3b 0d 09 09 09 69 66 | t = ROA|D;....if| |000051d0| 20 28 74 3d 3d 42 4f 41 | 54 29 20 63 2e 77 61 74 | (t==BOA|T) c.wat| |000051e0| 65 72 20 3d 20 63 2e 64 | 65 65 70 73 65 61 20 3d |er = c.d|eepsea =| |000051f0| 20 30 3b 09 09 09 2f 2f | 20 6f 6e 20 62 6f 61 74 | 0;...//| on boat| |00005200| 20 61 74 20 74 68 69 73 | 20 70 6f 69 6e 74 2c 20 | at this| point, | |00005210| 6e 6f 20 63 6f 73 74 0d | 09 09 09 65 6c 73 65 20 |no cost.|...else | |00005220| 69 66 20 28 68 69 74 73 | 20 7c 7c 20 28 74 20 21 |if (hits| || (t !| |00005230| 3d 20 52 49 56 45 52 20 | 26 26 20 74 20 21 3d 20 |= RIVER |&& t != | |00005240| 44 45 45 50 53 45 41 29 | 29 09 2f 2f 20 6e 6f 20 |DEEPSEA)|).// no | |00005250| 62 6f 61 74 2c 20 73 6f | 20 63 6f 75 6e 74 20 63 |boat, so| count c| |00005260| 6f 73 74 0d 09 09 09 09 | 7b 0d 09 09 09 09 69 66 |ost.....|{.....if| |00005270| 20 28 63 2e 64 65 65 70 | 73 65 61 29 20 6e 65 77 | (c.deep|sea) new| |00005280| 63 6f 73 74 20 3d 20 4d | 41 58 5f 43 4f 53 54 3b |cost = M|AX_COST;| |00005290| 0d 09 09 09 09 65 6c 73 | 65 20 7b 20 6e 65 77 5f |.....els|e { new_| |000052a0| 74 69 6d 65 63 6f 73 74 | 20 2b 3d 20 37 20 2a 20 |timecost| += 7 * | |000052b0| 63 2e 77 61 74 65 72 3b | 20 6e 65 77 5f 73 68 65 |c.water;| new_she| |000052c0| 6c 6c 63 6f 73 74 20 2b | 3d 20 36 20 2a 20 63 2e |llcost +|= 6 * c.| |000052d0| 77 61 74 65 72 3b 20 7d | 0d 09 09 09 09 63 2e 77 |water; }|.....c.w| |000052e0| 61 74 65 72 20 3d 20 63 | 2e 64 65 65 70 73 65 61 |ater = c|.deepsea| |000052f0| 20 3d 20 30 3b 09 2f 2f | 20 74 65 6e 74 61 74 69 | = 0;.//| tentati| |00005300| 76 65 20 63 6f 73 74 20 | 6e 6f 77 20 70 61 69 64 |ve cost |now paid| |00005310| 2c 20 73 6f 20 7a 65 72 | 6f 20 63 6f 75 6e 74 65 |, so zer|o counte| |00005320| 72 73 0d 09 09 09 09 7d | 0d 09 09 09 7d 0d 09 09 |rs.....}|....}...| |00005330| 2f 2f 65 6c 73 65 20 64 | 65 62 75 67 28 22 25 64 |//else d|ebug("%d| |00005340| 2c 20 25 64 20 63 61 6e | 20 73 68 6f 6f 74 20 25 |, %d can| shoot %| |00005350| 64 2c 20 25 64 22 2c 20 | 78 2c 20 79 2c 20 63 6f |d, %d", |x, y, co| |00005360| 73 74 74 61 72 67 65 74 | 5f 78 2c 20 63 6f 73 74 |sttarget|_x, cost| |00005370| 74 61 72 67 65 74 5f 79 | 29 3b 0d 09 09 0d 09 09 |target_y|);......| |00005380| 69 66 20 28 6e 65 77 5f | 74 69 6d 65 63 6f 73 74 |if (new_|timecost| |00005390| 20 20 20 3e 20 4d 41 58 | 5f 54 49 4d 45 5f 43 4f | > MAX|_TIME_CO| |000053a0| 53 54 29 20 20 20 6e 65 | 77 5f 74 69 6d 65 63 6f |ST) ne|w_timeco| |000053b0| 73 74 20 20 20 3d 20 4d | 41 58 5f 54 49 4d 45 5f |st = M|AX_TIME_| |000053c0| 43 4f 53 54 3b 0d 09 09 | 69 66 20 28 6e 65 77 5f |COST;...|if (new_| |000053d0| 73 68 65 6c 6c 63 6f 73 | 74 20 20 3e 20 4d 41 58 |shellcos|t > MAX| |000053e0| 5f 53 48 45 4c 4c 5f 43 | 4f 53 54 29 20 20 6e 65 |_SHELL_C|OST) ne| |000053f0| 77 5f 73 68 65 6c 6c 63 | 6f 73 74 20 20 3d 20 4d |w_shellc|ost = M| |00005400| 41 58 5f 53 48 45 4c 4c | 5f 43 4f 53 54 3b 0d 09 |AX_SHELL|_COST;..| |00005410| 09 69 66 20 28 6e 65 77 | 5f 61 72 6d 6f 75 72 63 |.if (new|_armourc| |00005420| 6f 73 74 20 3e 20 4d 41 | 58 5f 41 52 4d 4f 55 52 |ost > MA|X_ARMOUR| |00005430| 5f 43 4f 53 54 29 20 6e | 65 77 5f 61 72 6d 6f 75 |_COST) n|ew_armou| |00005440| 72 63 6f 73 74 20 3d 20 | 4d 41 58 5f 41 52 4d 4f |rcost = |MAX_ARMO| |00005450| 55 52 5f 43 4f 53 54 3b | 0d 09 0d 09 09 2f 2f 20 |UR_COST;|.....// | |00005460| 49 66 20 74 68 69 73 20 | 72 6f 75 74 65 20 63 6f |If this |route co| |00005470| 6e 73 75 6d 65 73 20 6d | 6f 72 65 20 61 72 6d 6f |nsumes m|ore armo| |00005480| 75 72 20 74 68 61 6e 20 | 77 65 20 68 61 76 65 2c |ur than |we have,| |00005490| 20 74 68 65 6e 20 69 74 | 20 69 73 20 75 6e 72 65 | then it| is unre| |000054a0| 61 63 68 61 62 6c 65 0d | 09 09 69 66 20 28 74 61 |achable.|..if (ta| |000054b0| 6e 6b 61 72 6d 6f 75 72 | 20 3c 20 6e 65 77 5f 61 |nkarmour| < new_a| |000054c0| 72 6d 6f 75 72 63 6f 73 | 74 29 20 6e 65 77 63 6f |rmourcos|t) newco| |000054d0| 73 74 20 3d 20 4d 41 58 | 5f 43 4f 53 54 3b 0d 09 |st = MAX|_COST;..| |000054e0| 09 0d 09 09 2f 2f 20 69 | 66 20 6e 65 77 63 6f 73 |....// i|f newcos| |000054f0| 74 20 68 61 73 20 6e 6f | 74 20 61 6c 72 65 61 64 |t has no|t alread| |00005500| 79 20 62 65 65 6e 20 73 | 65 74 20 74 6f 20 4d 41 |y been s|et to MA| |00005510| 58 5f 43 4f 53 54 20 28 | 69 65 20 69 6d 70 6f 73 |X_COST (|ie impos| |00005520| 73 69 62 6c 65 29 20 74 | 68 65 6e 20 63 61 6c 63 |sible) t|hen calc| |00005530| 75 6c 61 74 65 20 69 74 | 0d 09 09 69 66 20 28 6e |ulate it|...if (n| |00005540| 65 77 63 6f 73 74 20 3c | 20 4d 41 58 5f 43 4f 53 |ewcost <| MAX_COS| |00005550| 54 29 0d 09 09 09 7b 0d | 09 09 09 2f 2f 20 4d 61 |T)....{.|...// Ma| |00005560| 6b 65 20 73 75 72 65 20 | 77 65 20 64 6f 6e 27 74 |ke sure |we don't| |00005570| 20 64 69 76 69 64 65 20 | 62 79 20 7a 65 72 6f 0d | divide |by zero.| |00005580| 09 09 09 69 66 20 28 74 | 61 6e 6b 73 68 65 6c 6c |...if (t|ankshell| |00005590| 73 20 3e 20 6e 65 77 5f | 73 68 65 6c 6c 63 6f 73 |s > new_|shellcos| |000055a0| 74 20 29 20 74 61 6e 6b | 73 68 65 6c 6c 73 20 2d |t ) tank|shells -| |000055b0| 3d 20 6e 65 77 5f 73 68 | 65 6c 6c 63 6f 73 74 3b |= new_sh|ellcost;| |000055c0| 20 20 65 6c 73 65 20 74 | 61 6e 6b 73 68 65 6c 6c | else t|ankshell| |000055d0| 73 20 3d 20 31 3b 0d 09 | 09 09 69 66 20 28 74 61 |s = 1;..|..if (ta| |000055e0| 6e 6b 61 72 6d 6f 75 72 | 20 3e 20 6e 65 77 5f 61 |nkarmour| > new_a| |000055f0| 72 6d 6f 75 72 63 6f 73 | 74 29 20 74 61 6e 6b 61 |rmourcos|t) tanka| |00005600| 72 6d 6f 75 72 20 2d 3d | 20 6e 65 77 5f 61 72 6d |rmour -=| new_arm| |00005610| 6f 75 72 63 6f 73 74 3b | 20 65 6c 73 65 20 74 61 |ourcost;| else ta| |00005620| 6e 6b 61 72 6d 6f 75 72 | 20 3d 20 31 3b 0d 09 09 |nkarmour| = 1;...| |00005630| 09 6e 65 77 63 6f 73 74 | 20 3d 20 6e 65 77 5f 74 |.newcost| = new_t| |00005640| 69 6d 65 63 6f 73 74 20 | 2b 20 31 30 30 2f 74 61 |imecost |+ 100/ta| |00005650| 6e 6b 73 68 65 6c 6c 73 | 20 2b 20 32 30 30 2f 74 |nkshells| + 200/t| |00005660| 61 6e 6b 61 72 6d 6f 75 | 72 3b 0d 09 09 09 69 66 |ankarmou|r;....if| |00005670| 20 28 6e 65 77 63 6f 73 | 74 20 3e 20 4d 41 58 5f | (newcos|t > MAX_| |00005680| 43 4f 53 54 29 20 6e 65 | 77 63 6f 73 74 20 3d 20 |COST) ne|wcost = | |00005690| 4d 41 58 5f 43 4f 53 54 | 3b 0d 09 09 09 7d 0d 09 |MAX_COST|;....}..| |000056a0| 09 0d 09 09 63 70 63 6f | 73 74 20 3d 20 6e 65 77 |....cpco|st = new| |000056b0| 63 6f 73 74 20 2b 20 68 | 65 75 72 69 73 74 69 63 |cost + h|euristic| |000056c0| 3b 0d 09 09 69 66 20 28 | 63 70 63 6f 73 74 20 3e |;...if (|cpcost >| |000056d0| 20 4d 41 58 5f 43 4f 53 | 54 29 20 63 70 63 6f 73 | MAX_COS|T) cpcos| |000056e0| 74 20 3d 20 4d 41 58 5f | 43 4f 53 54 3b 0d 0d 09 |t = MAX_|COST;...| |000056f0| 09 69 66 20 28 43 50 43 | 6f 73 74 5b 63 2e 79 5d |.if (CPC|ost[c.y]| |00005700| 5b 63 2e 78 5d 20 3e 20 | 63 70 63 6f 73 74 29 09 |[c.x] > |cpcost).| |00005710| 0d 09 09 09 7b 0d 09 09 | 09 63 2e 74 69 6d 65 20 |....{...|.c.time | |00005720| 20 20 3d 20 6e 65 77 5f | 74 69 6d 65 63 6f 73 74 | = new_|timecost| |00005730| 3b 0d 09 09 09 63 2e 73 | 68 65 6c 6c 73 20 3d 20 |;....c.s|hells = | |00005740| 6e 65 77 5f 73 68 65 6c | 6c 63 6f 73 74 3b 0d 09 |new_shel|lcost;..| |00005750| 09 09 63 2e 61 72 6d 6f | 75 72 20 3d 20 6e 65 77 |..c.armo|ur = new| |00005760| 5f 61 72 6d 6f 75 72 63 | 6f 73 74 3b 0d 09 09 09 |_armourc|ost;....| |00005770| 63 2e 63 6f 73 74 20 20 | 20 3d 20 63 70 63 6f 73 |c.cost | = cpcos| |00005780| 74 3b 0d 09 09 09 0d 09 | 09 09 2f 2f 20 49 66 20 |t;......|..// If | |00005790| 77 65 20 61 72 65 20 6e | 6f 74 20 63 61 6c 63 75 |we are n|ot calcu| |000057a0| 6c 61 74 69 6e 67 20 61 | 20 62 6f 61 74 20 63 6f |lating a| boat co| |000057b0| 73 74 61 72 72 61 79 2c | 20 74 68 65 6e 20 74 68 |starray,| then th| |000057c0| 65 20 63 6f 73 74 20 66 | 69 65 6c 64 20 67 65 6e |e cost f|ield gen| |000057d0| 65 72 61 74 65 64 0d 09 | 09 09 2f 2f 20 73 68 6f |erated..|..// sho| |000057e0| 75 6c 64 20 69 6e 63 6c | 75 64 65 20 74 68 65 20 |uld incl|ude the | |000057f0| 77 61 74 65 72 20 63 6f | 73 74 73 20 73 6f 20 74 |water co|sts so t| |00005800| 68 61 74 20 74 68 65 20 | 74 61 6e 6b 20 69 73 20 |hat the |tank is | |00005810| 67 75 69 64 65 64 20 69 | 6e 20 74 68 65 20 72 69 |guided i|n the ri| |00005820| 67 68 74 0d 09 09 09 2f | 2f 20 64 69 72 65 63 74 |ght..../|/ direct| |00005830| 69 6f 6e 20 28 77 68 69 | 63 68 20 69 73 20 4e 4f |ion (whi|ch is NO| |00005840| 54 20 6e 65 63 65 73 73 | 61 72 69 6c 79 20 74 68 |T necess|arily th| |00005850| 65 20 73 61 6d 65 20 64 | 69 72 65 63 74 69 6f 6e |e same d|irection| |00005860| 20 74 68 65 20 73 65 61 | 72 63 68 20 69 73 20 74 | the sea|rch is t| |00005870| 61 6b 69 6e 67 29 2e 0d | 09 09 09 69 66 20 28 6e |aking)..|...if (n| |00005880| 65 77 63 6f 73 74 20 3c | 20 4d 41 58 5f 43 4f 53 |ewcost <| MAX_COS| |00005890| 54 20 26 26 20 21 63 6f | 73 74 61 72 72 61 79 5f |T && !co|starray_| |000058a0| 62 6f 61 74 29 0d 09 09 | 09 09 7b 0d 09 09 09 09 |boat)...|..{.....| |000058b0| 69 66 20 28 63 2e 64 65 | 65 70 73 65 61 29 20 6e |if (c.de|epsea) n| |000058c0| 65 77 63 6f 73 74 20 3d | 20 4d 41 58 5f 43 4f 53 |ewcost =| MAX_COS| |000058d0| 54 3b 0d 09 09 09 09 65 | 6c 73 65 0d 09 09 09 09 |T;.....e|lse.....| |000058e0| 09 7b 0d 09 09 09 09 09 | 69 66 20 28 74 61 6e 6b |.{......|if (tank| |000058f0| 73 68 65 6c 6c 73 20 3e | 20 36 20 2a 20 63 2e 77 |shells >| 6 * c.w| |00005900| 61 74 65 72 29 20 74 61 | 6e 6b 73 68 65 6c 6c 73 |ater) ta|nkshells| |00005910| 20 2d 3d 20 36 20 2a 20 | 63 2e 77 61 74 65 72 3b | -= 6 * |c.water;| |00005920| 0d 09 09 09 09 09 65 6c | 73 65 20 74 61 6e 6b 73 |......el|se tanks| |00005930| 68 65 6c 6c 73 20 3d 20 | 31 3b 0d 09 09 09 09 09 |hells = |1;......| |00005940| 6e 65 77 5f 74 69 6d 65 | 63 6f 73 74 20 20 2b 3d |new_time|cost +=| |00005950| 20 37 20 2a 20 63 2e 77 | 61 74 65 72 3b 0d 09 09 | 7 * c.w|ater;...| |00005960| 09 09 09 6e 65 77 63 6f | 73 74 20 3d 20 6e 65 77 |...newco|st = new| |00005970| 5f 74 69 6d 65 63 6f 73 | 74 20 2b 20 31 30 30 2f |_timecos|t + 100/| |00005980| 74 61 6e 6b 73 68 65 6c | 6c 73 20 2b 20 32 30 30 |tankshel|ls + 200| |00005990| 2f 74 61 6e 6b 61 72 6d | 6f 75 72 3b 0d 09 09 09 |/tankarm|our;....| |000059a0| 09 09 69 66 20 28 6e 65 | 77 63 6f 73 74 20 3e 20 |..if (ne|wcost > | |000059b0| 4d 41 58 5f 43 4f 53 54 | 29 20 6e 65 77 63 6f 73 |MAX_COST|) newcos| |000059c0| 74 20 3d 20 4d 41 58 5f | 43 4f 53 54 3b 0d 09 09 |t = MAX_|COST;...| |000059d0| 09 09 09 7d 0d 09 09 09 | 09 7d 0d 09 09 09 73 65 |...}....|.}....se| |000059e0| 74 63 6f 73 74 28 63 2c | 6e 65 77 63 6f 73 74 29 |tcost(c,|newcost)| |000059f0| 3b 0d 09 09 09 69 66 20 | 28 64 6f 5f 73 68 6f 77 |;....if |(do_show| |00005a00| 72 6f 75 74 65 29 20 73 | 68 6f 77 72 6f 75 74 65 |route) s|howroute| |00005a10| 28 63 2c 20 6e 65 77 63 | 6f 73 74 2c 20 21 63 6f |(c, newc|ost, !co| |00005a20| 75 6e 74 5f 63 6f 73 74 | 29 3b 0d 09 09 09 7d 0d |unt_cost|);....}.| |00005a30| 09 09 7d 0d 09 7d 0d 0d | 2f 2f 20 2a 2a 2a 2a 2a |..}..}..|// *****| |00005a40| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********| |00005a50| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********| |00005a60| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********| |00005a70| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********| |00005a80| 2a 2a 2a 2a 2a 2a 2a 0d | 0d 74 79 70 65 64 65 66 |*******.|.typedef| |00005a90| 20 76 6f 69 64 20 50 41 | 49 4e 54 5f 46 55 4e 43 | void PA|INT_FUNC| |00005aa0| 54 49 4f 4e 28 63 68 61 | 72 20 78 31 2c 20 63 68 |TION(cha|r x1, ch| |00005ab0| 61 72 20 78 32 2c 20 75 | 5f 63 68 61 72 33 32 20 |ar x2, u|_char32 | |00005ac0| 72 6f 77 29 3b 0d 0d 6c | 6f 63 61 6c 20 76 6f 69 |row);..l|ocal voi| |00005ad0| 64 20 70 5f 69 6e 63 72 | 65 6d 65 6e 74 28 63 68 |d p_incr|ement(ch| |00005ae0| 61 72 20 78 31 2c 20 63 | 68 61 72 20 78 32 2c 20 |ar x1, c|har x2, | |00005af0| 75 5f 63 68 61 72 33 32 | 20 72 6f 77 29 0d 09 7b |u_char32| row)..{| |00005b00| 0d 09 69 66 20 28 78 31 | 20 3e 20 43 4f 53 54 5f |..if (x1| > COST_| |00005b10| 41 52 52 41 59 5f 53 49 | 5a 45 2d 31 20 7c 7c 20 |ARRAY_SI|ZE-1 || | |00005b20| 78 32 20 3c 20 30 29 20 | 72 65 74 75 72 6e 3b 0d |x2 < 0) |return;.| |00005b30| 09 69 66 20 28 78 31 20 | 3c 20 30 20 20 20 20 20 |.if (x1 |< 0 | |00005b40| 20 20 20 20 20 20 20 20 | 20 20 20 29 20 78 31 20 | | ) x1 | |00005b50| 3d 20 30 3b 09 09 09 09 | 09 2f 2f 20 63 6c 69 70 |= 0;....|.// clip| |00005b60| 20 74 6f 20 6c 65 66 74 | 20 65 64 67 65 0d 09 69 | to left| edge..i| |00005b70| 66 20 28 78 32 20 3e 20 | 43 4f 53 54 5f 41 52 52 |f (x2 > |COST_ARR| |00005b80| 41 59 5f 53 49 5a 45 2d | 31 29 20 78 32 20 3d 20 |AY_SIZE-|1) x2 = | |00005b90| 43 4f 53 54 5f 41 52 52 | 41 59 5f 53 49 5a 45 2d |COST_ARR|AY_SIZE-| |00005ba0| 31 3b 09 2f 2f 20 63 6c | 69 70 20 74 6f 20 72 69 |1;.// cl|ip to ri| |00005bb0| 67 68 74 20 65 64 67 65 | 0d 09 77 68 69 6c 65 20 |ght edge|..while | |00005bc0| 28 78 31 3c 3d 78 32 29 | 20 72 6f 77 5b 78 31 2b |(x1<=x2)| row[x1+| |00005bd0| 2b 5d 2b 2b 3b 09 09 09 | 09 09 09 09 2f 2f 20 69 |+]++;...|....// i| |00005be0| 6e 63 72 65 6d 65 6e 74 | 20 68 69 74 20 63 6f 75 |ncrement| hit cou| |00005bf0| 6e 74 73 20 69 6e 20 74 | 68 69 73 20 72 6f 77 0d |nts in t|his row.| |00005c00| 09 7d 0d 0d 6c 6f 63 61 | 6c 20 76 6f 69 64 20 70 |.}..loca|l void p| |00005c10| 5f 63 6c 65 61 72 28 63 | 68 61 72 20 78 31 2c 20 |_clear(c|har x1, | |00005c20| 63 68 61 72 20 78 32 2c | 20 75 5f 63 68 61 72 33 |char x2,| u_char3| |00005c30| 32 20 72 6f 77 29 0d 09 | 7b 0d 09 69 66 20 28 78 |2 row)..|{..if (x| |00005c40| 31 20 3e 20 43 4f 53 54 | 5f 41 52 52 41 59 5f 53 |1 > COST|_ARRAY_S| |00005c50| 49 5a 45 2d 31 20 7c 7c | 20 78 32 20 3c 20 30 29 |IZE-1 ||| x2 < 0)| |00005c60| 20 72 65 74 75 72 6e 3b | 0d 09 69 66 20 28 78 31 | return;|..if (x1| |00005c70| 20 3c 20 30 20 20 20 20 | 20 20 20 20 20 20 20 20 | < 0 | | |00005c80| 20 20 20 20 29 20 78 31 | 20 3d 20 30 3b 09 09 09 | ) x1| = 0;...| |00005c90| 09 09 2f 2f 20 63 6c 69 | 70 20 74 6f 20 6c 65 66 |..// cli|p to lef| |00005ca0| 74 20 65 64 67 65 0d 09 | 69 66 20 28 78 32 20 3e |t edge..|if (x2 >| |00005cb0| 20 43 4f 53 54 5f 41 52 | 52 41 59 5f 53 49 5a 45 | COST_AR|RAY_SIZE| |00005cc0| 2d 31 29 20 78 32 20 3d | 20 43 4f 53 54 5f 41 52 |-1) x2 =| COST_AR| |00005cd0| 52 41 59 5f 53 49 5a 45 | 2d 31 3b 09 2f 2f 20 63 |RAY_SIZE|-1;.// c| |00005ce0| 6c 69 70 20 74 6f 20 72 | 69 67 68 74 20 65 64 67 |lip to r|ight edg| |00005cf0| 65 0d 09 77 68 69 6c 65 | 20 28 78 31 3c 3d 78 32 |e..while| (x1<=x2| |00005d00| 29 20 72 6f 77 5b 78 31 | 2b 2b 5d 20 3d 20 30 3b |) row[x1|++] = 0;| |00005d10| 09 09 09 09 09 09 2f 2f | 20 63 6c 65 61 72 20 68 |......//| clear h| |00005d20| 69 74 20 63 6f 75 6e 74 | 73 20 69 6e 20 74 68 69 |it count|s in thi| |00005d30| 73 20 72 6f 77 0d 09 7d | 0d 0d 6c 6f 63 61 6c 20 |s row..}|..local | |00005d40| 76 6f 69 64 20 70 61 69 | 6e 74 5f 63 69 72 63 6c |void pai|nt_circl| |00005d50| 65 28 50 41 49 4e 54 5f | 46 55 4e 43 54 49 4f 4e |e(PAINT_|FUNCTION| |00005d60| 20 70 2c 20 42 59 54 45 | 20 63 78 2c 20 42 59 54 | p, BYTE| cx, BYT| |00005d70| 45 20 63 79 2c 20 42 59 | 54 45 20 72 61 64 69 75 |E cy, BY|TE radiu| |00005d80| 73 29 0d 09 7b 0d 09 42 | 59 54 45 20 78 20 3d 20 |s)..{..B|YTE x = | |00005d90| 72 61 64 69 75 73 2c 20 | 79 20 3d 20 30 2c 20 79 |radius, |y = 0, y| |00005da0| 32 20 3d 20 72 61 64 69 | 75 73 3b 0d 09 73 68 6f |2 = radi|us;..sho| |00005db0| 72 74 20 64 20 3d 20 31 | 2d 72 61 64 69 75 73 3b |rt d = 1|-radius;| |00005dc0| 0d 09 69 66 20 28 49 4e | 5f 43 4f 53 54 41 52 52 |..if (IN|_COSTARR| |00005dd0| 41 59 28 63 79 29 29 20 | 70 28 63 78 20 2d 20 78 |AY(cy)) |p(cx - x| |00005de0| 2c 20 63 78 20 2b 20 78 | 2c 20 70 69 6c 6c 63 6f |, cx + x|, pillco| |00005df0| 76 65 72 61 67 65 5b 63 | 79 5d 29 3b 0d 09 77 68 |verage[c|y]);..wh| |00005e00| 69 6c 65 20 28 78 3e 79 | 29 0d 09 09 7b 0d 09 09 |ile (x>y|)...{...| |00005e10| 69 66 20 28 64 3c 30 29 | 20 64 20 2b 3d 20 32 2a |if (d<0)| d += 2*| |00005e20| 79 2b 33 3b 20 65 6c 73 | 65 20 7b 20 64 20 2b 3d |y+3; els|e { d +=| |00005e30| 20 32 2a 28 79 2d 78 29 | 2b 35 3b 20 78 2d 2d 3b | 2*(y-x)|+5; x--;| |00005e40| 20 7d 0d 09 09 79 2b 2b | 3b 0d 09 09 69 66 20 28 | }...y++|;...if (| |00005e50| 49 4e 5f 43 4f 53 54 41 | 52 52 41 59 28 63 79 2b |IN_COSTA|RRAY(cy+| |00005e60| 79 29 29 20 70 28 63 78 | 20 2d 20 78 2c 20 63 78 |y)) p(cx| - x, cx| |00005e70| 20 2b 20 78 2c 20 70 69 | 6c 6c 63 6f 76 65 72 61 | + x, pi|llcovera| |00005e80| 67 65 5b 28 42 59 54 45 | 29 28 63 79 20 2b 20 79 |ge[(BYTE|)(cy + y| |00005e90| 29 5d 29 3b 0d 09 09 69 | 66 20 28 49 4e 5f 43 4f |)]);...i|f (IN_CO| |00005ea0| 53 54 41 52 52 41 59 28 | 63 79 2d 79 29 29 20 70 |STARRAY(|cy-y)) p| |00005eb0| 28 63 78 20 2d 20 78 2c | 20 63 78 20 2b 20 78 2c |(cx - x,| cx + x,| |00005ec0| 20 70 69 6c 6c 63 6f 76 | 65 72 61 67 65 5b 28 42 | pillcov|erage[(B| |00005ed0| 59 54 45 29 28 63 79 20 | 2d 20 79 29 5d 29 3b 0d |YTE)(cy |- y)]);.| |00005ee0| 09 09 69 66 20 28 78 3c | 79 32 20 26 26 20 79 3c |..if (x<|y2 && y<| |00005ef0| 79 32 29 0d 09 09 09 7b | 0d 09 09 09 42 59 54 45 |y2)....{|....BYTE| |00005f00| 20 78 32 20 3d 20 79 2d | 31 3b 0d 09 09 09 69 66 | x2 = y-|1;....if| |00005f10| 20 28 49 4e 5f 43 4f 53 | 54 41 52 52 41 59 28 63 | (IN_COS|TARRAY(c| |00005f20| 79 2b 79 32 29 29 20 70 | 28 63 78 20 2d 20 78 32 |y+y2)) p|(cx - x2| |00005f30| 2c 20 63 78 20 2b 20 78 | 32 2c 20 70 69 6c 6c 63 |, cx + x|2, pillc| |00005f40| 6f 76 65 72 61 67 65 5b | 28 42 59 54 45 29 28 63 |overage[|(BYTE)(c| |00005f50| 79 20 2b 20 79 32 29 5d | 29 3b 0d 09 09 09 69 66 |y + y2)]|);....if| |00005f60| 20 28 49 4e 5f 43 4f 53 | 54 41 52 52 41 59 28 63 | (IN_COS|TARRAY(c| |00005f70| 79 2d 79 32 29 29 20 70 | 28 63 78 20 2d 20 78 32 |y-y2)) p|(cx - x2| |00005f80| 2c 20 63 78 20 2b 20 78 | 32 2c 20 70 69 6c 6c 63 |, cx + x|2, pillc| |00005f90| 6f 76 65 72 61 67 65 5b | 28 42 59 54 45 29 28 63 |overage[|(BYTE)(c| |00005fa0| 79 20 2d 20 79 32 29 5d | 29 3b 0d 09 09 09 79 32 |y - y2)]|);....y2| |00005fb0| 2d 2d 3b 0d 09 09 09 7d | 0d 09 09 7d 0d 09 7d 0d |--;....}|...}..}.| |00005fc0| 0d 6c 6f 63 61 6c 20 76 | 6f 69 64 20 73 63 61 6e |.local v|oid scan| |00005fd0| 5f 62 6f 75 6e 64 61 72 | 79 28 43 6f 73 74 50 6f |_boundar|y(CostPo| |00005fe0| 69 6e 74 20 63 2c 20 73 | 68 6f 72 74 20 64 69 72 |int c, s|hort dir| |00005ff0| 65 63 74 69 6f 6e 29 0d | 09 7b 0d 09 69 6e 74 20 |ection).|.{..int | |00006000| 69 3b 0d 09 42 59 54 45 | 20 2a 78 20 3d 20 26 63 |i;..BYTE| *x = &c| |00006010| 2e 78 2c 20 2a 79 20 3d | 20 26 63 2e 79 3b 0d 09 |.x, *y =| &c.y;..| |00006020| 69 66 20 28 64 69 72 65 | 63 74 69 6f 6e 3c 30 29 |if (dire|ction<0)| |00006030| 20 7b 20 78 20 3d 20 26 | 63 2e 79 3b 20 79 20 3d | { x = &|c.y; y =| |00006040| 20 26 63 2e 78 3b 20 7d | 0d 09 66 6f 72 20 28 69 | &c.x; }|..for (i| |00006050| 3d 30 3b 20 69 3c 31 34 | 3b 20 69 2b 2b 29 0d 09 |=0; i<14|; i++)..| |00006060| 09 7b 0d 09 09 69 66 20 | 28 28 2a 78 29 20 3d 3d |.{...if |((*x) ==| |00006070| 20 30 20 26 26 20 28 2a | 79 29 20 3e 20 30 29 20 | 0 && (*|y) > 0) | |00006080| 28 2a 79 29 2d 2d 3b 0d | 09 09 65 6c 73 65 20 69 |(*y)--;.|..else i| |00006090| 66 20 28 28 2a 79 29 20 | 3d 3d 20 43 4f 53 54 5f |f ((*y) |== COST_| |000060a0| 41 52 52 41 59 5f 53 49 | 5a 45 2d 31 29 20 28 2a |ARRAY_SI|ZE-1) (*| |000060b0| 78 29 2d 2d 3b 0d 09 09 | 65 6c 73 65 20 69 66 20 |x)--;...|else if | |000060c0| 28 28 2a 78 29 20 3d 3d | 20 43 4f 53 54 5f 41 52 |((*x) ==| COST_AR| |000060d0| 52 41 59 5f 53 49 5a 45 | 2d 31 29 20 28 2a 79 29 |RAY_SIZE|-1) (*y)| |000060e0| 2b 2b 3b 0d 09 09 65 6c | 73 65 20 69 66 20 28 28 |++;...el|se if ((| |000060f0| 2a 79 29 20 3d 3d 20 30 | 29 20 28 2a 78 29 2b 2b |*y) == 0|) (*x)++| |00006100| 3b 0d 09 09 73 65 74 63 | 6f 73 74 28 63 2c 20 30 |;...setc|ost(c, 0| |00006110| 29 3b 0d 09 09 69 66 20 | 28 64 6f 5f 73 68 6f 77 |);...if |(do_show| |00006120| 72 6f 75 74 65 29 20 73 | 68 6f 77 72 6f 75 74 65 |route) s|howroute| |00006130| 28 63 2c 20 30 2c 20 30 | 29 3b 0d 09 09 7d 0d 09 |(c, 0, 0|);...}..| |00006140| 7d 0d 0d 2f 2f 20 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |}..// **|********| |00006150| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********| |00006160| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********| |00006170| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********| |00006180| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********| |00006190| 2a 2a 0d 0d 6c 6f 63 61 | 6c 20 76 6f 69 64 20 63 |**..loca|l void c| |000061a0| 6f 6e 73 74 72 61 69 6e | 5f 73 75 62 74 61 72 67 |onstrain|_subtarg| |000061b0| 65 74 28 4d 41 50 5f 58 | 20 2a 74 78 2c 20 4d 41 |et(MAP_X| *tx, MA| |000061c0| 50 5f 59 20 2a 74 79 29 | 0d 09 7b 0d 09 4d 41 50 |P_Y *ty)|..{..MAP| |000061d0| 5f 58 20 63 6f 73 74 61 | 72 72 61 79 5f 72 69 67 |_X costa|rray_rig| |000061e0| 68 74 65 64 67 65 20 20 | 3d 20 63 6f 73 74 61 72 |htedge |= costar| |000061f0| 72 61 79 5f 6c 65 66 74 | 20 2b 20 43 4f 53 54 5f |ray_left| + COST_| |00006200| 41 52 52 41 59 5f 53 49 | 5a 45 2d 31 3b 0d 09 4d |ARRAY_SI|ZE-1;..M| |00006210| 41 50 5f 59 20 63 6f 73 | 74 61 72 72 61 79 5f 62 |AP_Y cos|tarray_b| |00006220| 6f 74 74 6f 6d 65 64 67 | 65 20 3d 20 63 6f 73 74 |ottomedg|e = cost| |00006230| 61 72 72 61 79 5f 74 6f | 70 20 20 2b 20 43 4f 53 |array_to|p + COS| |00006240| 54 5f 41 52 52 41 59 5f | 53 49 5a 45 2d 31 3b 0d |T_ARRAY_|SIZE-1;.| |00006250| 09 69 66 20 20 20 20 20 | 20 28 2a 74 78 20 3c 20 |.if | (*tx < | |00006260| 63 6f 73 74 61 72 72 61 | 79 5f 6c 65 66 74 20 20 |costarra|y_left | |00006270| 20 20 20 20 29 20 2a 74 | 78 20 3d 20 63 6f 73 74 | ) *t|x = cost| |00006280| 61 72 72 61 79 5f 6c 65 | 66 74 3b 0d 09 65 6c 73 |array_le|ft;..els| |00006290| 65 20 69 66 20 28 2a 74 | 78 20 3e 20 63 6f 73 74 |e if (*t|x > cost| |000062a0| 61 72 72 61 79 5f 72 69 | 67 68 74 65 64 67 65 20 |array_ri|ghtedge | |000062b0| 29 20 2a 74 78 20 3d 20 | 63 6f 73 74 61 72 72 61 |) *tx = |costarra| |000062c0| 79 5f 72 69 67 68 74 65 | 64 67 65 3b 0d 09 69 66 |y_righte|dge;..if| |000062d0| 20 20 20 20 20 20 28 2a | 74 79 20 3c 20 63 6f 73 | (*|ty < cos| |000062e0| 74 61 72 72 61 79 5f 74 | 6f 70 20 20 20 20 20 20 |tarray_t|op | |000062f0| 20 29 20 2a 74 79 20 3d | 20 63 6f 73 74 61 72 72 | ) *ty =| costarr| |00006300| 61 79 5f 74 6f 70 3b 0d | 09 65 6c 73 65 20 69 66 |ay_top;.|.else if| |00006310| 20 28 2a 74 79 20 3e 20 | 63 6f 73 74 61 72 72 61 | (*ty > |costarra| |00006320| 79 5f 62 6f 74 74 6f 6d | 65 64 67 65 29 20 2a 74 |y_bottom|edge) *t| |00006330| 79 20 3d 20 63 6f 73 74 | 61 72 72 61 79 5f 62 6f |y = cost|array_bo| |00006340| 74 74 6f 6d 65 64 67 65 | 3b 0d 09 7d 0d 0d 2f 2f |ttomedge|;..}..//| |00006350| 20 49 66 20 77 65 20 61 | 72 65 20 2a 73 68 6f 6f | If we a|re *shoo| |00006360| 74 69 6e 67 2a 20 61 74 | 20 73 6f 6d 65 74 68 69 |ting* at| somethi| |00006370| 6e 67 2c 20 74 74 79 70 | 65 20 77 69 6c 6c 20 69 |ng, ttyp|e will i| |00006380| 6e 64 69 63 61 74 65 20 | 77 68 61 74 20 69 74 20 |ndicate |what it | |00006390| 69 73 2c 20 73 6f 20 74 | 68 61 74 20 77 65 0d 2f |is, so t|hat we./| |000063a0| 2f 20 6b 6e 6f 77 20 77 | 65 20 64 6f 6e 27 74 20 |/ know w|e don't | |000063b0| 6e 65 65 64 20 74 6f 20 | 61 63 74 75 61 6c 6c 79 |need to |actually| |000063c0| 20 67 65 74 20 74 68 65 | 72 65 20 2d 2d 20 6a 75 | get the|re -- ju| |000063d0| 73 74 20 67 65 74 20 63 | 6c 6f 73 65 20 65 6e 6f |st get c|lose eno| |000063e0| 75 67 68 20 74 6f 20 73 | 68 6f 6f 74 20 69 74 2e |ugh to s|hoot it.| |000063f0| 0d 6c 6f 63 61 6c 20 75 | 5f 73 68 6f 72 74 20 6d |.local u|_short m| +--------+-------------------------+-------------------------+--------+--------+ Only 25.0 KB of data is shown above.